Thursday, 5 July 2012

Check WiFi & 3G availability on ANDROID device

Hi Folks,
I am trying to add some information about checking the network availability i.e. 3G and WiFi is ON or OFF on  ANDROID device.
Here is the method or code: 
ConnectivityManager manager = (ConnectivityManager) getSystemService(CONNECTIVITY_SERVICE);
//For 3G check
boolean is3g = manager.getNetworkInfo(ConnectivityManager.TYPE_MOBILE)

//For WiFi Check
boolean isWifi = manager.getNetworkInfo(ConnectivityManager.TYPE_WIFI)
System.out.println(is3g + " net " + isWifi);
if (!is3g && !isWifi) { Toast.makeText(getApplicationContext(),"Please make sure your Network Connection is ON ",Toast.LENGTH_LONG).show();
} else { 
        " Your method what you want to do "

1 comment: