-1

I have a TextView in my android appliation. Now I need to get a value from an ashx page. When I open that ashx page in browser, I can see that it is showing only a single value. I need to show that value in my TextView.

Please help me out...

Shoaib
  • 343
  • 2
  • 9

1 Answers1

0

get internet permission....and just run this code...

        try
        {
            HttpClient client=new DefaultHttpClient();
            HttpGet request=new HttpGet("http://173.45.66.154/VSServices/Export.ashx?f=GetClientBalance&pin=rsbtest&includeCurrency=true");
            HttpResponse response=client.execute(request);

            HttpEntity entity=response.getEntity();
            String resonseText=EntityUtils.toString(entity);
            textviewObject.setText(resonseText);

            entity.consumeContent();
        }
        catch(Exception e)
        {
            e.getStackTrace();
            Toast.makeText(MainActivity.this, e.toString()  , 0).show();
        }
Angad Tiwari
  • 1,738
  • 1
  • 12
  • 23
  • I'm getting an error : android.os.NetworkOnMainThreadException – Shoaib Oct 20 '14 at 07:33
  • :I've taken internet permission and tried with the code u given.. But getting error: android.os.NetworkOnMainThreadException – Shoaib Oct 20 '14 at 07:43
  • delete targetSdkversion line from manifest file...as the network operation is not allow to run on main thread..or you can make separate thread for that code – Angad Tiwari Oct 20 '14 at 07:43
  • It is not working. I have tried to call the function using another thread, also tried to call the function from another activity but getting the same error – Shoaib Oct 20 '14 at 08:51
  • ok let me try first ..mine eclipse is bit problematic right now...i will show you.... – Angad Tiwari Oct 20 '14 at 09:27