Disable enable internet connection in Android Emulator

If you try function for checking internet connection you can disable internet on the emulator:
Settings – Wireless and networks – Mobile networks – Data enabled (checked – unchecked )

 public boolean isNetworkAvailable() {
        ConnectivityManager cm = (ConnectivityManager) 
          getSystemService(Context.CONNECTIVITY_SERVICE);
        NetworkInfo networkInfo = cm.getActiveNetworkInfo();
        if (networkInfo != null && networkInfo.isConnected()) {
            return true;
        }
        return false;
    }

This entry was posted in Android Examples Code and tagged . Bookmark the permalink.


Comments are closed.



5,213 views