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:it.evilsocket.dsploit.net.Network.java
public boolean isConnected() { return mConnectivityManager.getNetworkInfo(ConnectivityManager.TYPE_WIFI).isConnected(); }
From source file:org.kei.android.phone.cellhistory.towers.MobileNetworkInfo.java
public static int getConnectivityStatus(final Context context) { final ConnectivityManager cm = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE); final NetworkInfo activeNetwork = cm.getActiveNetworkInfo(); if (null != activeNetwork) { if (activeNetwork.getType() == ConnectivityManager.TYPE_WIFI) return TYPE_WIFI; if (activeNetwork.getType() == ConnectivityManager.TYPE_MOBILE) return TYPE_MOBILE; }//from w w w. j av a2 s .c om return TYPE_NOT_CONNECTED; }
From source file:com.andrew.apollo.utils.ApolloUtils.java
/** * Used to determine if there is an active data connection and what type of * connection it is if there is one//from ww w . jav a2s .co m * * @param context The {@link Context} to use * @return True if there is an active data connection, false otherwise. * Also, if the user has checked to only download via Wi-Fi in the * settings, the mobile data and other network connections aren't * returned at all */ public static final boolean isOnline(final Context context) { /* * This sort of handles a sudden configuration change, but I think it * should be dealt with in a more professional way. */ if (context == null) { return false; } boolean state = false; final boolean onlyOnWifi = PreferenceUtils.getInstace(context).onlyOnWifi(); /* Monitor network connections */ final ConnectivityManager connectivityManager = (ConnectivityManager) context .getSystemService(Context.CONNECTIVITY_SERVICE); /* Wi-Fi connection */ final NetworkInfo wifiNetwork = connectivityManager.getNetworkInfo(ConnectivityManager.TYPE_WIFI); if (wifiNetwork != null) { state = wifiNetwork.isConnectedOrConnecting(); } /* Mobile data connection */ final NetworkInfo mbobileNetwork = connectivityManager.getNetworkInfo(ConnectivityManager.TYPE_MOBILE); if (mbobileNetwork != null) { if (!onlyOnWifi) { state = mbobileNetwork.isConnectedOrConnecting(); } } /* Other networks */ final NetworkInfo activeNetwork = connectivityManager.getActiveNetworkInfo(); if (activeNetwork != null) { if (!onlyOnWifi) { state = activeNetwork.isConnectedOrConnecting(); } } return state; }
From source file:com.otaupdater.utils.Utils.java
public static boolean wifiConnected(Context ctx) { ConnectivityManager cm = (ConnectivityManager) ctx.getSystemService(Context.CONNECTIVITY_SERVICE); NetworkInfo ni = cm.getActiveNetworkInfo(); return ni != null && ni.isConnected() && ni.getType() == ConnectivityManager.TYPE_WIFI; }
From source file:org.kontalk.util.SystemUtils.java
public static boolean isOnWifi(Context context) { return getCurrentNetworkType(context) == ConnectivityManager.TYPE_WIFI; }
From source file:itesm.mx.golpedecalor.SelectGroupActivity.java
public void onClickSincronizar(View v) { ConnectivityManager connManager = (ConnectivityManager) getSystemService(CONNECTIVITY_SERVICE); NetworkInfo mWifi = connManager.getNetworkInfo(ConnectivityManager.TYPE_WIFI); NetworkInfo mMobile = connManager.getNetworkInfo(ConnectivityManager.TYPE_MOBILE); if (mWifi.isConnected() || mMobile.isConnected()) { new RequestTask().execute("http://golpedecalor.comoj.com/dbHandler.php"); Toast.makeText(getApplicationContext(), "Sincronizacion Exitosa", Toast.LENGTH_SHORT).show(); } else {/*from w w w .ja v a 2 s . c o m*/ Toast.makeText(getApplicationContext(), "No hay conexin a internet", Toast.LENGTH_SHORT).show(); } }
From source file:com.nextgis.firereporter.HttpGetter.java
static boolean IsNetworkAvailible(Context c) { ConnectivityManager cm = (ConnectivityManager) c.getSystemService(Context.CONNECTIVITY_SERVICE); TelephonyManager tm = (TelephonyManager) c.getSystemService(Context.TELEPHONY_SERVICE); NetworkInfo info = cm.getActiveNetworkInfo(); if (info == null /*|| !cm.getBackgroundDataSetting()*/) return false; int netType = info.getType(); //int netSubtype = info.getSubtype(); if (netType == ConnectivityManager.TYPE_WIFI) { return info.isConnected(); } else if (netType == ConnectivityManager.TYPE_MOBILE && /*netSubtype == TelephonyManager.NETWORK_TYPE_UMTS &&*/ !tm.isNetworkRoaming()) { return info.isConnected(); } else {/*from w ww .j av a2 s. c o m*/ return false; } }
From source file:com.iflytek.android.framework.volley.toolbox.HurlStack.java
/** * @param context//w ww . j a v a2s. co m * @return ???<br\> * -1: 1:WIFI <br\> * 2:cmnet 3:cmwap <br\> * 4:ctnet 5:ctwap <br\> * ? 6:uninet 7:uniwap */ public static int getAPNType(Context context) { // ?wificmnet?cmwap??noneNet // ?wifi > cmnet >cmwap > noneNet ConnectivityManager connMgr = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE); NetworkInfo networkInfo = connMgr.getActiveNetworkInfo(); if (networkInfo == null) { return -1; } int nType = networkInfo.getType(); if (nType == ConnectivityManager.TYPE_WIFI) { // wifi return 1; } else if (nType == ConnectivityManager.TYPE_MOBILE) { String type = networkInfo.getExtraInfo(); Log.d("netType", "netType : " + type); if (type.equalsIgnoreCase("cmnet")) { // cmnet return 2; } else if (type.equalsIgnoreCase("cmwap")) { // cmwap return 3; } else if (type.equalsIgnoreCase("ctnet")) { // ctnet return 4; } else if (type.equalsIgnoreCase("ctwap")) { // ctwap return 5; } else if (type.equalsIgnoreCase("uninet")) { // uninet return 6; } else if (type.equalsIgnoreCase("uniwap")) { // uniwap return 7; } else { return 2; } } return -1; }
From source file:org.allseen.lsf.sampleapp.view.MainFragment.java
protected boolean isWifiConnected() { NetworkInfo wifiNetworkInfo = ((ConnectivityManager) getActivity() .getSystemService(Context.CONNECTIVITY_SERVICE)).getNetworkInfo(ConnectivityManager.TYPE_WIFI); // determine if wifi AP mode is on boolean isWifiApEnabled = false; WifiManager wifiManager = (WifiManager) getActivity().getSystemService(Context.WIFI_SERVICE); // need reflection because wifi ap is not in the public API try {/* w w w . j av a 2s .c om*/ Method isWifiApEnabledMethod = wifiManager.getClass().getDeclaredMethod("isWifiApEnabled"); isWifiApEnabled = (Boolean) isWifiApEnabledMethod.invoke(wifiManager); } catch (Exception e) { e.printStackTrace(); } //Log.d(SampleAppActivity.TAG, "Connectivity state " + wifiNetworkInfo.getState().name() + " - connected:" + wifiNetworkInfo.isConnected() + " hotspot:" + isWifiApEnabled); return wifiNetworkInfo.isConnected() || isWifiApEnabled; }
From source file:org.egov.android.view.activity.RegisterActivity.java
/** * internet connection test function//w ww . j a v a2 s. c om */ public boolean isInternetAvailable() { ConnectivityManager connectivity = (ConnectivityManager) getApplicationContext() .getSystemService(Context.CONNECTIVITY_SERVICE); NetworkInfo netInfo = connectivity.getNetworkInfo(ConnectivityManager.TYPE_WIFI); boolean available = false; if (netInfo.isConnected()) { available = true; } else { netInfo = connectivity.getNetworkInfo(ConnectivityManager.TYPE_MOBILE); available = netInfo.isConnected(); } return available; }