2014-10-20 99 views
-1

我在我的android應用程序中有一個TextView。現在我需要從ashx頁面獲得一個值。當我在瀏覽器中打開該ashx頁面時,我可以看到它只顯示一個值。我需要在我的TextView中顯示這個值。如何從ashx頁面獲取android中的字符串值?

請幫我...

+0

你能告訴我ashx的網頁...與網址.. ..? – 2014-10-20 07:03:53

+0

http://173.45.66.154/VSServices/Export.ashx?f=GetClientBalance&pin=rsbtest&includeCurrency=true – Shoaib 2014-10-20 07:04:16

+0

@AngadTiwari:這是 – Shoaib 2014-10-20 07:05:33

回答

0

獲取Internet權限....和公正運行這段代碼...

 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(); 
     } 
+0

的頁面讓我知道......它是否有效? – 2014-10-20 07:26:57

+0

我得到一個錯誤:android.os.NetworkOnMainThreadException – Shoaib 2014-10-20 07:33:21

+0

:我已經採取了互聯網許可,並嘗試與代碼你給..但獲取錯誤:android.os.NetworkOnMainThreadException – Shoaib 2014-10-20 07:43:17

相關問題