List of usage examples for android.net ConnectivityManager TYPE_WIFI
int TYPE_WIFI
To view the source code for android.net ConnectivityManager TYPE_WIFI.
Click Source Link
From source file:Main.java
public static String convertActiveConnectivityType(int type) { switch (type) { case ConnectivityManager.TYPE_MOBILE: return "MOBILE"; case ConnectivityManager.TYPE_WIFI: return "WiFi"; default://from ww w. j a v a2 s .c om return UNKNOWN; } }
From source file:Main.java
public static boolean isWifi(Context context) { ConnectivityManager manager = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE); NetworkInfo networkInfo = manager.getNetworkInfo(ConnectivityManager.TYPE_WIFI); return networkInfo.isConnected(); }
From source file:Main.java
public static boolean isConnectedToWifi(Context ctx) { ConnectivityManager connManager = (ConnectivityManager) ctx.getSystemService(Context.CONNECTIVITY_SERVICE); NetworkInfo mWifi = connManager.getNetworkInfo(ConnectivityManager.TYPE_WIFI); return mWifi != null && mWifi.isConnected(); }
From source file:Main.java
public static boolean checkStatusWifi(Context context) { ConnectivityManager manager = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE); NetworkInfo wifi = manager.getNetworkInfo(ConnectivityManager.TYPE_WIFI); if (wifi != null) { return wifi.isConnected(); } else/* w ww. j a va2s.c o m*/ return false; }
From source file:Main.java
public static boolean getWifiState(Context context) { ConnectivityManager cm = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE); State wifistate = cm.getNetworkInfo(ConnectivityManager.TYPE_WIFI).getState(); if (wifistate != State.CONNECTED) { return false; }//from ww w . j a va 2 s .com State mobileState = cm.getNetworkInfo(ConnectivityManager.TYPE_MOBILE).getState(); boolean ret = State.CONNECTED != mobileState; return ret; }
From source file:Main.java
public static boolean getMobileState(Context context) { ConnectivityManager cm = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE); State wifistate = cm.getNetworkInfo(ConnectivityManager.TYPE_WIFI).getState(); if (wifistate != State.CONNECTED) { return false; }/*from w w w .j a v a2 s . c o m*/ State mobileState = cm.getNetworkInfo(ConnectivityManager.TYPE_MOBILE).getState(); boolean ret = State.CONNECTED == mobileState; return ret; }
From source file:Main.java
public static boolean isWifi(Context context) { ConnectivityManager cm = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE); if (cm == null) return false; return cm.getActiveNetworkInfo().getType() == ConnectivityManager.TYPE_WIFI; }
From source file:Main.java
private static boolean isWIFIConnection(Context context) { ConnectivityManager manager = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE); NetworkInfo networkInfo = manager.getNetworkInfo(ConnectivityManager.TYPE_WIFI); if (networkInfo != null) { return networkInfo.isConnected(); }/*from w ww . ja va2 s . co m*/ return false; }
From source file:Main.java
public static boolean hasConnection(Context c) { ConnectivityManager cm = (ConnectivityManager) c.getSystemService(Context.CONNECTIVITY_SERVICE); NetworkInfo wifiNetwork = cm.getNetworkInfo(ConnectivityManager.TYPE_WIFI); if (wifiNetwork != null && wifiNetwork.isConnected()) { return true; }/*from ww w .j a v a 2 s. com*/ NetworkInfo mobileNetwork = cm.getNetworkInfo(ConnectivityManager.TYPE_MOBILE); if (mobileNetwork != null && mobileNetwork.isConnected()) { return true; } NetworkInfo activeNetwork = cm.getActiveNetworkInfo(); if (activeNetwork != null && activeNetwork.isConnected()) { return true; } return false; }
From source file:Main.java
public static boolean isWifiOn(Context context) { ConnectivityManager connManager = (ConnectivityManager) context .getSystemService(Context.CONNECTIVITY_SERVICE); NetworkInfo mWifi = connManager.getNetworkInfo(ConnectivityManager.TYPE_WIFI); return mWifi.isConnected(); }