Android Network State Check isConnected(NetworkInfo info)

Here you can find the source of isConnected(NetworkInfo info)

Description

is Connected

Declaration

public static boolean isConnected(NetworkInfo info) 

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);
    }//from w  w  w  . j  a va2s  . co  m

    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. hasMobileConnectivity(Context context)
  2. hasNoConnectivity(Application application)
  3. isConnected(Context context)
  4. isConnected(Context context)
  5. isConnected(Context context)
  6. isConnected(final Context context, final int... networkTypes)
  7. isConnected(final NetworkInfo info)
  8. isConnectedFast(Context context)
  9. isConnectedMobile(Context context)