Example usage for android.net NetworkInfo isConnected

List of usage examples for android.net NetworkInfo isConnected

Introduction

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

Prototype

@Deprecated
public boolean isConnected() 

Source Link

Document

Indicates whether network connectivity exists and it is possible to establish connections and pass data.

Usage

From source file:Main.java

public static boolean networkConnected(Activity activity) {
    ConnectivityManager conManager = (ConnectivityManager) activity
            .getSystemService(Context.CONNECTIVITY_SERVICE);
    NetworkInfo networkInfo = conManager.getActiveNetworkInfo();
    return networkInfo != null && networkInfo.isConnected();
}

From source file:Main.java

public static boolean isConnected(Context context) {
    ConnectivityManager connManager = (ConnectivityManager) context
            .getSystemService(Context.CONNECTIVITY_SERVICE);
    NetworkInfo networkInfo = connManager.getActiveNetworkInfo();
    return networkInfo != null && networkInfo.isConnected();
}

From source file:Main.java

public static boolean isWifiConnected(final Context context) {
    final ConnectivityManager cm = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
    final NetworkInfo networkInfo = cm.getActiveNetworkInfo();
    return networkInfo != null && networkInfo.isConnected()
            && networkInfo.getTypeName().equalsIgnoreCase("WIFI");
}

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 inetAvailable(Context context) {
    ConnectivityManager connMgr = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
    NetworkInfo networkInfo = connMgr.getActiveNetworkInfo();
    if (networkInfo != null && networkInfo.isConnected()) {

        return true;

    }/*from   www . jav  a  2  s  .c o m*/
    return false;
}

From source file:Main.java

public static boolean isConnectingToInternet(Context context) {
    try {/* w ww . ja va  2 s .co  m*/
        ConnectivityManager cm = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
        NetworkInfo netInfo = cm.getActiveNetworkInfo();
        if (netInfo != null && netInfo.isConnected()) {
            return true;
        }
    } catch (Exception e) {
        e.printStackTrace();
        return false;
    }
    return false;
}

From source file:Main.java

public final static boolean isNetWorkConnected(Context ctx) {
    ConnectivityManager manager = (ConnectivityManager) ctx.getSystemService(Context.CONNECTIVITY_SERVICE);
    NetworkInfo network = manager.getActiveNetworkInfo();
    if (network != null && network.isConnected()) {
        if (network.getState() == NetworkInfo.State.CONNECTED) {
            return true;
        }//from   w ww .  jav  a2 s  .  c  o m
    }
    return false;
}

From source file:Main.java

public static boolean isNetworkAvaliable(Context context) {

    ConnectivityManager cm = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);

    NetworkInfo networkInfo = cm.getActiveNetworkInfo();

    if (networkInfo != null && networkInfo.isConnected()) {
        return true;
    }/*  w w w  .ja  va2  s  .  c  o  m*/

    return false;
}

From source file:Main.java

public static boolean isNetworkAvailable(Context ctx) {
    if (ctx == null) {
        return false;
    }/*from  ww  w .  j  a  v a 2 s  .c  o  m*/
    ConnectivityManager connMgr = (ConnectivityManager) ctx.getSystemService(Context.CONNECTIVITY_SERVICE);
    NetworkInfo networkInfo = connMgr.getActiveNetworkInfo();
    return (networkInfo != null && networkInfo.isConnected());
}

From source file:Main.java

public static boolean networkCanUse(Context context) {
    ConnectivityManager connectivityManager = (ConnectivityManager) context
            .getSystemService(Context.CONNECTIVITY_SERVICE);
    NetworkInfo netinfo = connectivityManager.getActiveNetworkInfo();
    if (netinfo != null && netinfo.isConnected()) {
        return true;
    }//from w ww  . j a  v  a2s  .  co  m
    return false;
}