![](/img/trans.png)
[英]Android app works fine on Emulator, but not on Device. Uses Internet Connection
[英]Android emulator internet connection issues - real device works.
我正在嘗試從網站獲取JSON格式的文本。 它可以在我真正的智能手機上完美運行,但不能在Android Emulator(4.0.3)中運行。 檢查互聯網連接是否正常:
ConnectivityManager connMgr = (ConnectivityManager) getSystemService(Activity.CONNECTIVITY_SERVICE);
NetworkInfo networkInfo = connMgr.getActiveNetworkInfo();
if (networkInfo != null && networkInfo.isConnected())
return true;
else
return false;
這給我的模擬器一個空的結果,但是我在手機中得到了一些東西:
HttpClient httpclient = new DefaultHttpClient();
HttpResponse httpResponse = httpclient.execute(new HttpGet(url));
inputStream = httpResponse.getEntity().getContent();
if (inputStream != null)
result = convertInputStreamToString(inputStream);
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.