简体   繁体   English

Eclipse Android Emulator无法连接到互联网

[英]Eclipse Android Emulator doesn't connect to internet

I have created an app that uses a web-service (from www.worldweatheronline.com) to acquire certain information but it seems that it doesn't have access to the internet and I get "Unfortunately, Browser has stopped". 我创建了一个使用Web服务(来自www.worldweatheronline.com)来获取某些信息的应用程序,但似乎它无法访问互联网,并且出现“不幸的是,浏览器已停止”。 I say this because when trying to use the emulator's browser it doesn't respond at all and I have tried to use Additional Emulator Command Line Options: -dns-server 8.8.8.8,8.8.4.4 我说这是因为,当尝试使用仿真器的浏览器时,它根本不响应,并且我尝试使用其他仿真器命令行选项:-dns-server 8.8.8.8,8.8.4.4

I have also added internet permissions to the manifest: 我还为清单添加了Internet权限:

<uses-permission android:name="android.permission.INTERNET" /> 

Any suggestions? 有什么建议么?

Thanks 谢谢

You need to set proxy setting in your emulator,probably proxy is blocking your internet connection. 您需要在模拟器中设置代理设置,可能代理阻止了您的Internet连接。 Try this 尝试这个

  1. Go to setting in Emulator 转到模拟器中的设置
  2. Open Internet Setting, and create a new APN 打开“ Internet设置”,然后创建一个新的APN
  3. Over proxy and Port just enter the proxy settings you are using (eg setting from IE) 通过代理和端口,只需输入您正在使用的代理设置(例如,来自IE的设置)
  4. Choose this APN, and you are good to go. 选择此APN,就可以了。

To check internet connection. 检查互联网连接。 Try this sample code- 试试这个示例代码-

boolean b_IsConnect = isNetworkAvailable();
private boolean isNetworkAvailable() {
        ConnectivityManager connectivityManager = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE);
        NetworkInfo activeNetworkInfo = connectivityManager
                .getActiveNetworkInfo();
        return activeNetworkInfo != null;
    }

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM