Android Network State Check isConnected(Context context)

Here you can find the source of isConnected(Context context)

Description

is Connected

Declaration

public static boolean isConnected(Context context) 

Method Source Code

//package com.java2s;
import android.content.Context;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;

public class Main {
    public static boolean isConnected(Context context) {
        NetworkInfo info = getNetworkInfo(context);
        return isConnected(info);
    }/*  w  w w  . j a v  a2  s  .c  om*/

    public static boolean isConnected(NetworkInfo info) {
        return info != null && info.isConnected();
    }

    public static NetworkInfo getNetworkInfo(Context context) {
        ConnectivityManager cm = (ConnectivityManager) context
                .getSystemService(Context.CONNECTIVITY_SERVICE);
        return cm.getActiveNetworkInfo();
    }
}

Related

  1. hasConnectivity(final Context context, final int... networkTypes)
  2. hasConnectivity(final NetworkInfo info)
  3. hasInternetAvailable(Context context)
  4. hasMobileConnectivity(Context context)
  5. hasNoConnectivity(Application application)
  6. isConnected(Context context)
  7. isConnected(Context context)
  8. isConnected(NetworkInfo info)
  9. isConnected(final Context context, final int... networkTypes)