Android Utililty Methods Network State Check

List of utility methods to do Network State Check

Description

The list of methods to do Network State Check are organized into topic(s).

Method

booleanCheckInternet(Activity a)
Check Internet
ConnectivityManager connec = (ConnectivityManager) a
        .getBaseContext().getSystemService(
                Context.CONNECTIVITY_SERVICE);
android.net.NetworkInfo wifi = connec
        .getNetworkInfo(ConnectivityManager.TYPE_WIFI);
android.net.NetworkInfo mobile = connec
        .getNetworkInfo(ConnectivityManager.TYPE_MOBILE);
if (wifi.isConnected()) {
...
booleancheckInternetConnection(Context context)
check Internet Connection
boolean haveConnectedWifi = false;
boolean haveConnectedMobile = false;
ConnectivityManager cm = (ConnectivityManager) context
        .getSystemService(Context.CONNECTIVITY_SERVICE);
try {
    NetworkInfo[] netInfo = cm.getAllNetworkInfo();
    for (NetworkInfo ni : netInfo) {
        if (ni.getTypeName().equalsIgnoreCase("WIFI"))
...