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 isWifiAvailable(Context context) { ConnectivityManager mConnMgr = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE); NetworkInfo mWifi = mConnMgr.getNetworkInfo(ConnectivityManager.TYPE_WIFI); boolean flag = false; if ((mWifi != null) && ((mWifi.isAvailable()))) { if ((mWifi.isConnected())) { flag = true;//from w w w . j a v a 2 s . c o m } } return flag; }
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); if (wifiNetworkInfo.isConnected()) { return true; }//w ww . j a va2 s . c om return false; }
From source file:Main.java
public static boolean isNetworkAvailable(Context context) { try {//from w w w .j av a2 s .co m ConnectivityManager connMgr = (ConnectivityManager) context .getSystemService(Context.CONNECTIVITY_SERVICE); if (connMgr.getNetworkInfo(ConnectivityManager.TYPE_WIFI).getState() == NetworkInfo.State.CONNECTED || connMgr.getNetworkInfo(ConnectivityManager.TYPE_WIFI) .getState() == NetworkInfo.State.CONNECTING) { return true; } else if (connMgr.getNetworkInfo(ConnectivityManager.TYPE_MOBILE) .getState() == NetworkInfo.State.CONNECTED || connMgr.getNetworkInfo(ConnectivityManager.TYPE_MOBILE) .getState() == NetworkInfo.State.CONNECTING) { return true; } else return false; } catch (Exception e) { return false; } }
From source file:Main.java
public static boolean isNetworkAvailable(Context context) { ConnectivityManager mConnMgr = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE); NetworkInfo mWifi = mConnMgr.getNetworkInfo(ConnectivityManager.TYPE_WIFI); NetworkInfo mMobile = mConnMgr.getNetworkInfo(ConnectivityManager.TYPE_MOBILE); boolean flag = false; if ((mWifi != null) && ((mWifi.isAvailable()) || (mMobile.isAvailable()))) { if ((mWifi.isConnected()) || (mMobile.isConnected())) { flag = true;/*from w ww . j av a2 s . c o m*/ } } return flag; }
From source file:Main.java
public static boolean isWifi(Context context) { ConnectivityManager cm = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE); NetworkInfo networkINfo = cm.getActiveNetworkInfo(); if (networkINfo != null && networkINfo.getType() == ConnectivityManager.TYPE_WIFI) { return true; }/*from w w w . ja v a2 s . co m*/ return 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; }//from w w w. ja v a2 s .com return false; }
From source file:Main.java
public static boolean isWifiConnect(Context context) { ConnectivityManager cm = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE); NetworkInfo networkINfo = cm.getActiveNetworkInfo(); if (networkINfo != null && networkINfo.getType() == ConnectivityManager.TYPE_WIFI) { return true; }/* w w w .j a v a 2 s . c om*/ return false; }
From source file:Main.java
public static boolean isConnectedToWifi(Context ctx) { ConnectivityManager cm = (ConnectivityManager) ctx.getSystemService(Context.CONNECTIVITY_SERVICE); NetworkInfo activeNetwork = cm.getActiveNetworkInfo(); return activeNetwork != null && activeNetwork.getType() == ConnectivityManager.TYPE_WIFI; }
From source file:Main.java
public static boolean checkNetworkConnection(Context context) { ConnectivityManager cm = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE); State wifi = cm.getNetworkInfo(ConnectivityManager.TYPE_WIFI).getState(); if (wifi == State.CONNECTED) { return true; }/* w w w . j ava 2 s . co m*/ State mobile = cm.getNetworkInfo(ConnectivityManager.TYPE_MOBILE).getState(); if (mobile == State.CONNECTED) { TelephonyManager tm = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE); int type = tm.getNetworkType(); if (type != TelephonyManager.NETWORK_TYPE_CDMA && type != TelephonyManager.NETWORK_TYPE_EDGE && type != TelephonyManager.NETWORK_TYPE_GPRS) { return true; } } return false; }
From source file:Main.java
public static final boolean hasWifiConnection(Context context) { final ConnectivityManager connectivityManager = (ConnectivityManager) context .getSystemService(Context.CONNECTIVITY_SERVICE); final NetworkInfo networkInfo = connectivityManager.getNetworkInfo(ConnectivityManager.TYPE_WIFI); return (networkInfo != null && networkInfo.isAvailable()); }