[英]Android emulator internet connection issues - real device works.
I´m trying to get a JSON-Format text from a website. 我正在尝试从网站获取JSON格式的文本。 It works perfectly on my real smartphone, but it don´t works in the Android Emulator(4.0.3).
它可以在我真正的智能手机上完美运行,但不能在Android Emulator(4.0.3)中运行。 Checking Internet Connection is positive with this one:
检查互联网连接是否正常:
ConnectivityManager connMgr = (ConnectivityManager) getSystemService(Activity.CONNECTIVITY_SERVICE);
NetworkInfo networkInfo = connMgr.getActiveNetworkInfo();
if (networkInfo != null && networkInfo.isConnected())
return true;
else
return false;
That gives me empty result in my emulator, but I get something in my phone: 这给我的模拟器一个空的结果,但是我在手机中得到了一些东西:
HttpClient httpclient = new DefaultHttpClient();
HttpResponse httpResponse = httpclient.execute(new HttpGet(url));
inputStream = httpResponse.getEntity().getContent();
if (inputStream != null)
result = convertInputStreamToString(inputStream);
Read through this, it should solve your problem: 通读此书,它应该可以解决您的问题:
http://www.gitshah.com/2011/02/android-fixing-no-internet-connection.html http://www.gitshah.com/2011/02/android-fixing-no-internet-connection.html
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.