Example usage for android.net ConnectivityManager TYPE_WIFI

List of usage examples for android.net ConnectivityManager TYPE_WIFI

Introduction

In this page you can find the example usage for android.net ConnectivityManager TYPE_WIFI.

Prototype

int TYPE_WIFI

To view the source code for android.net ConnectivityManager TYPE_WIFI.

Click Source Link

Document

A WIFI data connection.

Usage

From source file:Main.java

public static boolean isWIFIConnected(Context context) {
    ConnectivityManager manager = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
    NetworkInfo info = manager.getNetworkInfo(ConnectivityManager.TYPE_WIFI);
    return info != null && info.isConnected();
}

From source file:Main.java

public static boolean isWifiOnline(Context context) {
    ConnectivityManager conMan = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);

    State wifi = conMan.getNetworkInfo(ConnectivityManager.TYPE_WIFI).getState();

    return wifi == State.CONNECTED;
}

From source file:Main.java

public static boolean isMobileOrWifiConneciton(Context context) {

    ConnectivityManager connManager = (ConnectivityManager) context
            .getSystemService(Context.CONNECTIVITY_SERVICE);
    NetworkInfo mWifi = connManager.getNetworkInfo(ConnectivityManager.TYPE_WIFI);
    NetworkInfo mMobile = connManager.getNetworkInfo(ConnectivityManager.TYPE_MOBILE);

    if (mWifi.isAvailable() == false && mMobile.isAvailable() == false) {
        return false;
    }/*from   w w  w.j a  va 2 s .  c  o m*/

    return true;
}

From source file:Main.java

public static boolean isWifiAvailable(Context context) {
    ConnectivityManager connectivityManager = (ConnectivityManager) context
            .getSystemService(Context.CONNECTIVITY_SERVICE);
    NetworkInfo wifiNetworkInfo = connectivityManager.getNetworkInfo(ConnectivityManager.TYPE_WIFI);
    return wifiNetworkInfo.isAvailable();

}

From source file:Main.java

public static boolean isWifiConnected(Context context) {
    ConnectivityManager mgr = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
    if (mgr == null)
        return false;
    NetworkInfo info = mgr.getNetworkInfo(ConnectivityManager.TYPE_WIFI);
    if (info == null)
        return false;
    NetworkInfo.State state = info.getState();
    return state == NetworkInfo.State.CONNECTED || state == NetworkInfo.State.CONNECTING;
}

From source file:Main.java

private static boolean isWifiConnected(Context context) {
    ConnectivityManager connectivityManager = (ConnectivityManager) context
            .getSystemService(Context.CONNECTIVITY_SERVICE);
    NetworkInfo wifiNetworkInfo = connectivityManager.getNetworkInfo(ConnectivityManager.TYPE_WIFI);
    return wifiNetworkInfo != null && wifiNetworkInfo.isConnected();
}

From source file:Main.java

public static boolean isWifiConnected(Context context) {
    ConnectivityManager connectivityManager = (ConnectivityManager) context
            .getSystemService(Context.CONNECTIVITY_SERVICE);
    NetworkInfo wifiNetworkInfo = connectivityManager.getNetworkInfo(ConnectivityManager.TYPE_WIFI);
    return wifiNetworkInfo.isConnected();
}

From source file:Main.java

public static boolean isConnectedToWifi(Context context) {
    ConnectivityManager connec = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
    NetworkInfo wifi = connec.getNetworkInfo(ConnectivityManager.TYPE_WIFI);

    if (wifi != null && wifi.isConnected()) {
        return true;
    } else {//from  ww w  . j a v a 2  s  .com
        return false;
    }

}

From source file:Main.java

public static boolean isWifiDataEnable(Context context) {
    ConnectivityManager connectivityManager = (ConnectivityManager) context
            .getSystemService(Context.CONNECTIVITY_SERVICE);
    boolean isWifiDataEnable = false;
    isWifiDataEnable = connectivityManager.getNetworkInfo(ConnectivityManager.TYPE_WIFI)
            .isConnectedOrConnecting();/*from w w w . j a v  a 2  s  .c o m*/
    return isWifiDataEnable;
}

From source file:Main.java

public static boolean isWifiDataEnable(Context context) {
    ConnectivityManager connectivityManager = (ConnectivityManager) context
            .getSystemService(Context.CONNECTIVITY_SERVICE);

    NetworkInfo networkInfo = connectivityManager.getNetworkInfo(ConnectivityManager.TYPE_WIFI);
    if (networkInfo == null)
        return false;

    return networkInfo.isConnectedOrConnecting();
}