List of usage examples for android.net ConnectivityManager TYPE_BLUETOOTH
int TYPE_BLUETOOTH
To view the source code for android.net ConnectivityManager TYPE_BLUETOOTH.
Click Source Link
From source file:Main.java
/** * get mobile NetWork Type// ww w.jav a 2s. c o m * * @param context * @return */ public static String getNetWorkType(Context context) { ConnectivityManager connectivityManager = (ConnectivityManager) context .getSystemService(Context.CONNECTIVITY_SERVICE); NetworkInfo workinfo = connectivityManager.getActiveNetworkInfo(); if (workinfo != null) { if (workinfo.getType() == ConnectivityManager.TYPE_BLUETOOTH) { return "b"; } if (workinfo.getType() == ConnectivityManager.TYPE_MOBILE) { return "m"; } if (workinfo.getType() == ConnectivityManager.TYPE_WIFI) { return "w"; } } return null; }
From source file:com.air.mobilebrowser.NetworkUtil.java
/** * Check the current status of internet connectivity. * This method iterates over the available network interfaces and * checks for an active connection./* w ww. j a v a2 s .co m*/ * @return true if a connection was detected, false otherwise. */ public static boolean haveInternetConnection(Context context) { if (context != null) { ConnectivityManager connectivityMgr = (ConnectivityManager) context .getSystemService(Context.CONNECTIVITY_SERVICE); NetworkInfo wifiInfo = connectivityMgr.getNetworkInfo(ConnectivityManager.TYPE_WIFI); NetworkInfo mobile = connectivityMgr.getNetworkInfo(ConnectivityManager.TYPE_MOBILE); NetworkInfo wimax = connectivityMgr.getNetworkInfo(ConnectivityManager.TYPE_WIMAX); NetworkInfo blue = connectivityMgr.getNetworkInfo(ConnectivityManager.TYPE_BLUETOOTH); NetworkInfo ether = connectivityMgr.getNetworkInfo(ConnectivityManager.TYPE_ETHERNET); boolean hasInternet = false; if (wifiInfo != null && wifiInfo.getState() == NetworkInfo.State.CONNECTED) { hasInternet = true; } else if (mobile != null && mobile.getState() == NetworkInfo.State.CONNECTED) { hasInternet = true; } else if (wimax != null && wimax.getState() == NetworkInfo.State.CONNECTED) { hasInternet = true; } else if (blue != null && blue.getState() == NetworkInfo.State.CONNECTED) { hasInternet = true; } else if (ether != null && ether.getState() == NetworkInfo.State.CONNECTED) { hasInternet = true; } return hasInternet; } return false; }
From source file:dev.ukanth.ufirewall.InterfaceTracker.java
private static InterfaceDetails getInterfaceDetails(Context context) { InterfaceDetails ret = new InterfaceDetails(); ConnectivityManager cm = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE); NetworkInfo info = cm.getActiveNetworkInfo(); if (info == null || info.isConnected() == false) { return ret; }/* w ww . j a v a 2 s . co m*/ switch (info.getType()) { case ConnectivityManager.TYPE_MOBILE: case ConnectivityManager.TYPE_MOBILE_DUN: case ConnectivityManager.TYPE_MOBILE_HIPRI: case ConnectivityManager.TYPE_MOBILE_MMS: case ConnectivityManager.TYPE_MOBILE_SUPL: case ConnectivityManager.TYPE_WIMAX: ret.isRoaming = info.isRoaming(); ret.netType = ConnectivityManager.TYPE_MOBILE; ret.netEnabled = true; break; case ConnectivityManager.TYPE_WIFI: case ConnectivityManager.TYPE_BLUETOOTH: case ConnectivityManager.TYPE_ETHERNET: ret.netType = ConnectivityManager.TYPE_WIFI; ret.netEnabled = true; break; } getTetherStatus(context, ret); if (Build.VERSION.SDK_INT < Build.VERSION_CODES.GINGERBREAD) { OldInterfaceScanner.populateLanMasks(context, ITFS_WIFI, ret); } else { NewInterfaceScanner.populateLanMasks(context, ITFS_WIFI, ret); } return ret; }
From source file:com.android.providers.downloads.DownloadInfo.java
/** * Translate a ConnectivityManager.TYPE_* constant to the corresponding * DownloadManager.Request.NETWORK_* bit flag. */// w ww.jav a 2 s. c o m private int translateNetworkTypeToApiFlag(int networkType) { switch (networkType) { case ConnectivityManager.TYPE_MOBILE: return DownloadManager.Request.NETWORK_MOBILE; case ConnectivityManager.TYPE_WIFI: return DownloadManager.Request.NETWORK_WIFI; case ConnectivityManager.TYPE_BLUETOOTH: return DownloadManager.Request.NETWORK_BLUETOOTH; default: return 0; } }
From source file:at.alladin.rmbt.android.util.InformationCollector.java
/** Returns the network that the phone is on (e.g. Wifi, Edge, GPRS, etc). */ public int getNetwork() { int result = TelephonyManager.NETWORK_TYPE_UNKNOWN; if (connManager != null) { final NetworkInfo activeNetworkInfo = connManager.getActiveNetworkInfo(); if (activeNetworkInfo != null) { final int type = activeNetworkInfo.getType(); switch (type) { case ConnectivityManager.TYPE_WIFI: result = NETWORK_WIFI;/*ww w. j a v a 2s . c o m*/ break; case ConnectivityManager.TYPE_BLUETOOTH: result = NETWORK_BLUETOOTH; break; case ConnectivityManager.TYPE_ETHERNET: result = NETWORK_ETHERNET; break; case ConnectivityManager.TYPE_MOBILE: case ConnectivityManager.TYPE_MOBILE_DUN: case ConnectivityManager.TYPE_MOBILE_HIPRI: case ConnectivityManager.TYPE_MOBILE_MMS: case ConnectivityManager.TYPE_MOBILE_SUPL: result = telManager.getNetworkType(); break; } } } /* detect change from wifi to mobile or reverse */ final int lastNetworkType = this.lastNetworkType.get(); if (result != TelephonyManager.NETWORK_TYPE_UNKNOWN && lastNetworkType != TelephonyManager.NETWORK_TYPE_UNKNOWN) { if ((result == ConnectivityManager.TYPE_WIFI && lastNetworkType != ConnectivityManager.TYPE_WIFI) || (result != ConnectivityManager.TYPE_WIFI && lastNetworkType == ConnectivityManager.TYPE_WIFI)) illegalNetworkTypeChangeDetcted.set(true); } if (result != lastNetworkType) { this.lastNetworkType.set(result); if (telListener != null) telListener.onSignalStrengthsChanged(null); } return result; }
From source file:com.shinymayhem.radiopresets.ServiceRadioPlayer.java
protected int getConnectionType() { int newState = mNetworkInfo.getType(); if (LOCAL_LOGV) { String str = ""; switch (newState) { case ConnectivityManager.TYPE_WIFI: str += "wifi"; break; case ConnectivityManager.TYPE_MOBILE: str += "mobile"; break; case ConnectivityManager.TYPE_MOBILE_DUN: str += "mobile-dun"; break; case ConnectivityManager.TYPE_MOBILE_HIPRI: str += "moblie-hipri"; break; case ConnectivityManager.TYPE_MOBILE_MMS: str += "mobile-mms"; break; case ConnectivityManager.TYPE_MOBILE_SUPL: str += "mobile-supl"; break; case ConnectivityManager.TYPE_WIMAX: str += "wimax"; break; case ConnectivityManager.TYPE_ETHERNET: str += "ethernet"; break; case ConnectivityManager.TYPE_BLUETOOTH: str += "bluetooth"; break; case ConnectivityManager.TYPE_DUMMY: str += "dummy"; break; }//from w ww .ja v a2 s .co m str += " detected"; log(str, "v"); } return newState; }