Example usage for android.net NetworkInfo isAvailable

List of usage examples for android.net NetworkInfo isAvailable

Introduction

In this page you can find the example usage for android.net NetworkInfo isAvailable.

Prototype

@Deprecated
public boolean isAvailable() 

Source Link

Document

Indicates whether network connectivity is possible.

Usage

From source file:Main.java

public static boolean isNetworkConnected(Context context) {
    ConnectivityManager cm = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
    NetworkInfo ni = cm.getActiveNetworkInfo();
    return ni != null && ni.isAvailable();
}

From source file:Main.java

public static boolean isAvailable(Context context) {
    ConnectivityManager cm = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
    NetworkInfo info = cm.getActiveNetworkInfo();
    return info != null && info.isAvailable();
}

From source file:Main.java

public static boolean hasInternet(Context context) {
    ConnectivityManager cm = (ConnectivityManager) context.getApplicationContext()
            .getSystemService(Context.CONNECTIVITY_SERVICE);
    NetworkInfo info = cm.getActiveNetworkInfo();
    return info != null && info.isAvailable() && info.isConnected();
}

From source file:Main.java

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

From source file:Main.java

public static boolean net_is_active(Context context) {
    ConnectivityManager mgrConn = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
    NetworkInfo info = mgrConn.getActiveNetworkInfo();
    return (info != null && info.isAvailable());
}

From source file:Main.java

public static boolean isNetWorkAvalible(Context context) {
    ConnectivityManager cm = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
    if (cm == null) {
        return false;
    }//www .ja  v a 2  s  .co m
    NetworkInfo ni = cm.getActiveNetworkInfo();
    if (ni == null || !ni.isAvailable()) {
        return false;
    }
    return true;
}

From source file:Main.java

public static boolean isNetworkAvailable(Context context) {
    ConnectivityManager mgr = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
    if (mgr == null)
        return false;
    NetworkInfo info = mgr.getActiveNetworkInfo();
    return info != null && info.isAvailable();
}

From source file:Main.java

public static boolean isNetConnect(@NonNull Context context) {
    ConnectivityManager service = (ConnectivityManager) context.getApplicationContext()
            .getSystemService(Context.CONNECTIVITY_SERVICE);
    NetworkInfo info = service.getActiveNetworkInfo();

    return info != null && info.isAvailable();
}

From source file:Main.java

public static boolean isNetworkAvailable(Context context) {
    ConnectivityManager cManager = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
    NetworkInfo info = cManager.getActiveNetworkInfo();
    if (info != null && info.isAvailable()) {
        return true;
    } else {/*from w  ww  . j av a2  s. c o m*/
        return false;
    }
}

From source file:Main.java

public static boolean isNetworkOn(Context context) {
    ConnectivityManager cm = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
    NetworkInfo networkInfo = cm.getActiveNetworkInfo();
    return networkInfo != null && networkInfo.isAvailable() && networkInfo.isConnectedOrConnecting();
}