简体   繁体   中英

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". 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

I have also added internet permissions to the manifest:

<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. Try this

  1. Go to setting in Emulator
  2. Open Internet Setting, and create a new APN
  3. Over proxy and Port just enter the proxy settings you are using (eg setting from IE)
  4. Choose this APN, and you are good to go.

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;
    }

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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