List of usage examples for android.net NetworkInfo getTypeName
@Deprecated
public String getTypeName()
From source file:it.sasabz.android.sasabus.classes.hafas.XMLAsyncRequest.java
/** * this method checks if a networkconnection is active or not * @return boolean if the network is reachable or not *///from w w w . ja v a2 s. c o m private boolean haveNetworkConnection() { boolean haveConnectedWifi = false; boolean haveConnectedMobile = false; ConnectivityManager cm = (ConnectivityManager) (activity.getSystemService(Context.CONNECTIVITY_SERVICE)); NetworkInfo[] netInfo = cm.getAllNetworkInfo(); for (NetworkInfo ni : netInfo) { //testing WIFI connection if (ni.getTypeName().equalsIgnoreCase("WIFI")) if (ni.isConnected()) haveConnectedWifi = true; //testing GPRS/EDGE/UMTS/HDSPA/HUSPA/LTE connection if (ni.getTypeName().equalsIgnoreCase("MOBILE")) if (ni.isConnected()) haveConnectedMobile = true; } return haveConnectedWifi || haveConnectedMobile; }
From source file:org.openremote.android.console.Main.java
/** * Check net type./*w w w .ja v a2s .c om*/ * It is used for ipAutoDiscovery, if net type is not wifi, * multicast to non wifi address. */ private void checkNetType() { ConnectivityManager conn = (ConnectivityManager) (this).getSystemService(Context.CONNECTIVITY_SERVICE); NetworkInfo info = conn.getActiveNetworkInfo(); String type = info == null ? null : info.getTypeName(); if (type != null && "wifi".equals(type.toLowerCase())) { IPAutoDiscoveryClient.isNetworkTypeWIFI = true; } else { IPAutoDiscoveryClient.isNetworkTypeWIFI = false; } }
From source file:it.sasabz.android.sasabus.InfoActivity.java
/** * this method checks if a networkconnection is active or not * @return boolean if the network is reachable or not *///from www . j a va2s.com private boolean haveNetworkConnection() { boolean haveConnectedWifi = false; boolean haveConnectedMobile = false; ConnectivityManager cm = (ConnectivityManager) (this.getSystemService(Context.CONNECTIVITY_SERVICE)); NetworkInfo[] netInfo = cm.getAllNetworkInfo(); for (NetworkInfo ni : netInfo) { //testing WIFI connection if (ni.getTypeName().equalsIgnoreCase("WIFI")) if (ni.isConnected()) haveConnectedWifi = true; //testing GPRS/EDGE/UMTS/HDSPA/HUSPA/LTE connection if (ni.getTypeName().equalsIgnoreCase("MOBILE")) if (ni.isConnected()) haveConnectedMobile = true; } return haveConnectedWifi || haveConnectedMobile; }
From source file:jieehd.villain.updater.checkInBackground.java
public boolean haveNetworkConnection(Context mContext) { boolean haveConnectedWifi = false; boolean haveConnectedMobile = false; ConnectivityManager cm = (ConnectivityManager) mContext.getSystemService(Context.CONNECTIVITY_SERVICE); NetworkInfo[] netInfo = cm.getAllNetworkInfo(); for (NetworkInfo ni : netInfo) { if (ni.getTypeName().equalsIgnoreCase("WIFI")) if (ni.isConnected()) haveConnectedWifi = true; if (ni.getTypeName().equalsIgnoreCase("MOBILE")) if (ni.isConnected()) haveConnectedMobile = true; }/*from w w w .jav a 2 s. c o m*/ return haveConnectedWifi || haveConnectedMobile; }
From source file:com.polyvi.xface.extension.XNetworkConnectionExt.java
/** * .//from w ww. ja va 2s .co m * * @param info ?? * @return ? */ private String getType(NetworkInfo info) { if (null != info) { String type = info.getTypeName(); if (type.toLowerCase().equals(WIFI)) { return TYPE_WIFI; } else if (type.toLowerCase().equals(MOBILE)) { type = info.getSubtypeName(); if (type.toLowerCase().equals(GSM) || type.toLowerCase().equals(GPRS) || type.toLowerCase().equals(EDGE)) { return TYPE_2G; } else if (type.toLowerCase().startsWith(CDMA) || type.toLowerCase().equals(UMTS) || type.toLowerCase().equals(ONEXRTT) || type.toLowerCase().equals(EHRPD) || type.toLowerCase().equals(HSUPA) || type.toLowerCase().equals(HSDPA) || type.toLowerCase().equals(HSPA)) { return TYPE_3G; } else if (type.toLowerCase().equals(LTE) || type.toLowerCase().equals(UMB) || type.toLowerCase().equals(HSPA_PLUS)) { return TYPE_4G; } } } else { return TYPE_NONE; } return TYPE_UNKNOWN; }
From source file:org.apache.cordova.core.NetworkManager.java
/** * Determine the type of connection/* w w w . j a va 2 s . c o m*/ * * @param info the network info so we can determine connection type. * @return the type of mobile network we are on */ private String getType(NetworkInfo info) { if (info != null) { String type = info.getTypeName(); if (type.toLowerCase().equals(WIFI)) { return TYPE_WIFI; } else if (type.toLowerCase().equals(MOBILE)) { type = info.getSubtypeName(); if (type.toLowerCase().equals(GSM) || type.toLowerCase().equals(GPRS) || type.toLowerCase().equals(EDGE)) { return TYPE_2G; } else if (type.toLowerCase().startsWith(CDMA) || type.toLowerCase().equals(UMTS) || type.toLowerCase().equals(ONEXRTT) || type.toLowerCase().equals(EHRPD) || type.toLowerCase().equals(HSUPA) || type.toLowerCase().equals(HSDPA) || type.toLowerCase().equals(HSPA)) { return TYPE_3G; } else if (type.toLowerCase().equals(LTE) || type.toLowerCase().equals(UMB) || type.toLowerCase().equals(HSPA_PLUS)) { return TYPE_4G; } } } else { return TYPE_NONE; } return TYPE_UNKNOWN; }
From source file:com.example.testplayer.NetworkManager.java
/** * Determine the type of connection/*from w ww . j ava 2 s .c om*/ * * @param info the network info so we can determine connection type. * @return the type of mobile network we are on */ private String getType(NetworkInfo info) { if (info != null) { String type = info.getTypeName().toLowerCase(Locale.US); Log.d("CordovaNetworkManager", "toLower : " + type.toLowerCase()); Log.d("CordovaNetworkManager", "wifi : " + WIFI); if (type.equals(WIFI)) { return TYPE_WIFI; } else if (type.toLowerCase().equals(TYPE_ETHERNET)) { return TYPE_ETHERNET; } else if (type.equals(MOBILE) || type.equals(CELLULAR)) { type = info.getSubtypeName().toLowerCase(Locale.US); if (type.equals(GSM) || type.equals(GPRS) || type.equals(EDGE)) { return TYPE_2G; } else if (type.startsWith(CDMA) || type.equals(UMTS) || type.equals(ONEXRTT) || type.equals(EHRPD) || type.equals(HSUPA) || type.equals(HSDPA) || type.equals(HSPA)) { return TYPE_3G; } else if (type.equals(LTE) || type.equals(UMB) || type.equals(HSPA_PLUS)) { return TYPE_4G; } } } else { return TYPE_NONE; } return TYPE_UNKNOWN; }
From source file:org.wso2.iot.agent.services.AgentStartupReceiver.java
private boolean isNetworkConnected(Context context, Intent intent) { if (intent.getExtras() != null) { final ConnectivityManager connectivityManager = (ConnectivityManager) context .getSystemService(Context.CONNECTIVITY_SERVICE); final NetworkInfo ni = connectivityManager.getActiveNetworkInfo(); if (ni != null && ni.isConnectedOrConnecting()) { if (Constants.DEBUG_MODE_ENABLED) { Log.d(TAG, "Network " + ni.getTypeName() + " connected"); }/*w ww.j a va2 s . co m*/ return true; } else if (intent.getBooleanExtra(ConnectivityManager.EXTRA_NO_CONNECTIVITY, Boolean.FALSE)) { Log.i(TAG, "There's no network connectivity"); } } return false; }
From source file:com.facebook.react.modules.netinfo.NetInfoModule.java
private String getCurrentConnectionType() { try {/*www. ja v a 2 s . co m*/ NetworkInfo networkInfo = mConnectivityManager.getActiveNetworkInfo(); if (networkInfo == null || !networkInfo.isConnected()) { return CONNECTION_TYPE_NONE; } else if (ConnectivityManager.isNetworkTypeValid(networkInfo.getType())) { return networkInfo.getTypeName().toUpperCase(); } else { return CONNECTION_TYPE_UNKNOWN; } } catch (SecurityException e) { mNoNetworkPermission = true; return CONNECTION_TYPE_UNKNOWN; } }
From source file:pe.kr.crasy.parse_launch.MainActivity.java
License:asdf
public String isWifi() { ConnectivityManager connectivityManager = (ConnectivityManager) MainActivity.this .getSystemService(Context.CONNECTIVITY_SERVICE); NetworkInfo wifi = connectivityManager.getActiveNetworkInfo(); if (wifi == null) { return "AirMode"; } else {/*from w ww . j a va 2s. c o m*/ return wifi.getTypeName(); } }