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 boolean isWifiConnected(Context context) { final ConnectivityManager connMgr = (ConnectivityManager) context .getSystemService(Context.CONNECTIVITY_SERVICE); final android.net.NetworkInfo wifi = connMgr.getNetworkInfo(ConnectivityManager.TYPE_WIFI); if (wifi.isAvailable()) return true; else/*from w ww . j a v a 2 s . c om*/ return false; }
From source file:Main.java
public static boolean hasConnection(Context context) { ConnectivityManager cm = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE); NetworkInfo wifiNetwork = cm.getNetworkInfo(ConnectivityManager.TYPE_WIFI); if (wifiNetwork != null && wifiNetwork.isConnected()) { return true; }// www. j av a 2s . co m 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 isConnectedWifi(Context context) { ConnectivityManager connManager = (ConnectivityManager) context .getSystemService(Context.CONNECTIVITY_SERVICE); NetworkInfo mWifi = connManager.getNetworkInfo(ConnectivityManager.TYPE_WIFI); return mWifi.isConnected(); }
From source file:Main.java
public static NetworkInfo.State getWifiConnectState(Context context) { ConnectivityManager manager = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE); NetworkInfo mWiFiNetworkInfo = manager.getNetworkInfo(ConnectivityManager.TYPE_WIFI); if (mWiFiNetworkInfo != null) { return mWiFiNetworkInfo.getState(); }//from w w w . jav a 2 s .co m return NetworkInfo.State.DISCONNECTED; }
From source file:Main.java
public static boolean isOnWifiInternet(Context context) { ConnectivityManager connManager = (ConnectivityManager) context .getSystemService(Context.CONNECTIVITY_SERVICE); NetworkInfo info = connManager.getNetworkInfo(ConnectivityManager.TYPE_WIFI); return (info.isAvailable() && info.isConnected()); }
From source file:Main.java
public static boolean checkWifiConnection(Context context) { final ConnectivityManager connMgr = (ConnectivityManager) context .getSystemService(Context.CONNECTIVITY_SERVICE); final NetworkInfo wifi = connMgr.getNetworkInfo(ConnectivityManager.TYPE_WIFI); if (wifi.isAvailable()) return true; else//w w w . j a v a 2s . co m return false; }
From source file:Main.java
public static boolean isWiFi(Context context) { NetworkInfo networkInfo = ((ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE)) .getActiveNetworkInfo();/*from w ww . ja va 2 s . co m*/ return (networkInfo != null && networkInfo.getType() == ConnectivityManager.TYPE_WIFI); }
From source file:Main.java
public static boolean checkNetworkConnection(Context context) { final ConnectivityManager connMgr = (ConnectivityManager) context .getSystemService(Context.CONNECTIVITY_SERVICE); final NetworkInfo wifi = connMgr.getNetworkInfo(ConnectivityManager.TYPE_WIFI); final NetworkInfo mobile = connMgr.getNetworkInfo(ConnectivityManager.TYPE_MOBILE); if (wifi.isAvailable() || mobile.isAvailable()) return true; else/*from w w w . j a va2s .c o m*/ return false; }
From source file:Main.java
public static boolean isWifiConnected(Context context) { ConnectivityManager connectivityManager = (ConnectivityManager) context .getSystemService(Context.CONNECTIVITY_SERVICE); NetworkInfo wifiInfo = connectivityManager.getNetworkInfo(ConnectivityManager.TYPE_WIFI); return wifiInfo.isConnected(); }
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; }