Example usage for android.net NetworkInfo getType

List of usage examples for android.net NetworkInfo getType

Introduction

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

Prototype

@Deprecated
public int getType() 

Source Link

Document

Reports the type of network to which the info in this NetworkInfo pertains.

Usage

From source file:Main.java

public static boolean checkMobileNET(Context cxt) {
    ConnectivityManager cm = (ConnectivityManager) cxt.getSystemService(Context.CONNECTIVITY_SERVICE);
    NetworkInfo activeNetwork = cm.getActiveNetworkInfo();
    if (activeNetwork.getType() == ConnectivityManager.TYPE_MOBILE)
        return true;
    else//from  ww w . j  a  v  a 2  s  .  c  o m
        return false;

}

From source file:Main.java

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

From source file:Main.java

public static boolean isMobile(Context context) {
    NetworkInfo info = getNetworkInfo(context);
    return null != info && info.getType() == ConnectivityManager.TYPE_MOBILE;
}

From source file:Main.java

public static boolean isWIFI(Context context) {
    NetworkInfo info = getNetworkInfo(context);
    return null != info && info.getType() == ConnectivityManager.TYPE_WIFI;
}

From source file:Main.java

static public boolean isNetworkType(NetworkInfo networkInfo, int type) {
    return networkInfo != null && networkInfo.getType() == type;
}

From source file:Main.java

public static boolean isOnlineOnWifi(Context c) {
    ConnectivityManager cm = (ConnectivityManager) c.getSystemService(Context.CONNECTIVITY_SERVICE);
    NetworkInfo network = cm.getActiveNetworkInfo();

    return network != null && network.getType() == ConnectivityManager.TYPE_WIFI;
}

From source file:Main.java

public static boolean isWiFiConnected(Context context) {
    ConnectivityManager connectivityManager = (ConnectivityManager) context
            .getSystemService(Context.CONNECTIVITY_SERVICE);
    NetworkInfo networkInfo = connectivityManager.getActiveNetworkInfo();
    return networkInfo.getType() == ConnectivityManager.TYPE_WIFI ? true : false;
}

From source file:Main.java

public static boolean isWifiConnected(Context context) {
    ConnectivityManager conMan = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
    NetworkInfo netInfo = conMan.getActiveNetworkInfo();
    if (netInfo != null && netInfo.getType() == ConnectivityManager.TYPE_WIFI) {
        return true;
    }/*ww  w  .j  a v a 2 s  . co m*/
    return false;
}

From source file:Main.java

private static boolean isWifiContected(Context context) {
    ConnectivityManager cm = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
    NetworkInfo ni = cm.getActiveNetworkInfo();
    return ni != null && ni.getType() == ConnectivityManager.TYPE_WIFI;

}

From source file:Main.java

public static boolean checkWifiNetwork(Context context) {
    boolean has = false;
    ConnectivityManager connectivity = (ConnectivityManager) context
            .getSystemService(Context.CONNECTIVITY_SERVICE);
    NetworkInfo info = connectivity.getActiveNetworkInfo();
    int netType = info.getType();
    int netSubtype = info.getSubtype();
    if (netType == ConnectivityManager.TYPE_WIFI) {
        has = info.isConnected();/*  w ww.  ja v a 2s .c om*/
    }
    return has;
}