List of usage examples for android.net ConnectivityManager TYPE_MOBILE
int TYPE_MOBILE
To view the source code for android.net ConnectivityManager TYPE_MOBILE.
Click Source Link
From source file:com.moez.QKSMS.mmssms.Transaction.java
/** * @deprecated/*from w w w .ja v a2s .com*/ */ private int beginMmsConnectivity() { if (LOCAL_LOGV) Log.v(TAG, "starting mms service"); return mConnMgr.startUsingNetworkFeature(ConnectivityManager.TYPE_MOBILE, "enableMMS"); }
From source file:com.ferdi2005.secondgram.voip.VoIPService.java
@Override public void onConnectionStateChanged(int newState) { if (newState == STATE_FAILED) { callFailed();/*from ww w . jav a 2 s. c om*/ return; } if (newState == STATE_ESTABLISHED) { if (spPlayID != 0) { soundPool.stop(spPlayID); spPlayID = 0; } AndroidUtilities.runOnUIThread(new Runnable() { @Override public void run() { if (controller == null) return; int netType = StatsController.TYPE_WIFI; if (lastNetInfo != null) { if (lastNetInfo.getType() == ConnectivityManager.TYPE_MOBILE) netType = lastNetInfo.isRoaming() ? StatsController.TYPE_ROAMING : StatsController.TYPE_MOBILE; } StatsController.getInstance().incrementTotalCallsTime(netType, 5); AndroidUtilities.runOnUIThread(this, 5000); } }, 5000); if (isOutgoing) StatsController.getInstance().incrementSentItemsCount(getStatsNetworkType(), StatsController.TYPE_CALLS, 1); else StatsController.getInstance().incrementReceivedItemsCount(getStatsNetworkType(), StatsController.TYPE_CALLS, 1); } dispatchStateChanged(newState); }
From source file:at.alladin.rmbt.android.main.RMBTMainActivity.java
/** * //from w ww . j av a2 s . c o m * @param context * @return */ public static boolean isNetworkAvailable(Context context) { boolean isMobile = false, isWifi = false; try { NetworkInfo[] infoAvailableNetworks = ((ConnectivityManager) context .getSystemService(Context.CONNECTIVITY_SERVICE)).getAllNetworkInfo(); if (infoAvailableNetworks != null) { for (NetworkInfo network : infoAvailableNetworks) { if (network.getType() == ConnectivityManager.TYPE_WIFI) { if (network.isConnected() && network.isAvailable()) isWifi = true; } if (network.getType() == ConnectivityManager.TYPE_MOBILE) { if (network.isConnected() && network.isAvailable()) isMobile = true; } } } return isMobile || isWifi; } catch (Exception e) { return false; } }
From source file:com.ferdi2005.secondgram.voip.VoIPService.java
private void updateNetworkType() { ConnectivityManager cm = (ConnectivityManager) getSystemService(CONNECTIVITY_SERVICE); NetworkInfo info = cm.getActiveNetworkInfo(); lastNetInfo = info;//from w w w.j av a 2 s .c o m int type = VoIPController.NET_TYPE_UNKNOWN; if (info != null) { switch (info.getType()) { case ConnectivityManager.TYPE_MOBILE: switch (info.getSubtype()) { case TelephonyManager.NETWORK_TYPE_GPRS: type = VoIPController.NET_TYPE_GPRS; break; case TelephonyManager.NETWORK_TYPE_EDGE: case TelephonyManager.NETWORK_TYPE_1xRTT: type = VoIPController.NET_TYPE_EDGE; break; case TelephonyManager.NETWORK_TYPE_UMTS: case TelephonyManager.NETWORK_TYPE_EVDO_0: type = VoIPController.NET_TYPE_3G; break; case TelephonyManager.NETWORK_TYPE_HSDPA: case TelephonyManager.NETWORK_TYPE_HSPA: case TelephonyManager.NETWORK_TYPE_HSPAP: case TelephonyManager.NETWORK_TYPE_HSUPA: case TelephonyManager.NETWORK_TYPE_EVDO_A: case TelephonyManager.NETWORK_TYPE_EVDO_B: type = VoIPController.NET_TYPE_HSPA; break; case TelephonyManager.NETWORK_TYPE_LTE: type = VoIPController.NET_TYPE_LTE; break; default: type = VoIPController.NET_TYPE_OTHER_MOBILE; break; } break; case ConnectivityManager.TYPE_WIFI: type = VoIPController.NET_TYPE_WIFI; break; case ConnectivityManager.TYPE_ETHERNET: type = VoIPController.NET_TYPE_ETHERNET; break; } } if (controller != null) { controller.setNetworkType(type); } }
From source file:com.ubiLive.GameCloud.Browser.WebBrowser.java
private void processNetworkType(Intent intent, Context context) { int netType;/*from w w w .j a v a 2s .c om*/ int netSubtype; int networkType; boolean isConnected; String reloadUrl; DebugLog.d(TAG, "processNetworkType() enter"); NetworkInfo netInfo = Utils.getCurNetworkInfo(context); if (netInfo == null || netInfo.isAvailable() == false) { DebugLog.d(TAG, "getCurNetworkInfo() is null"); netInfo = (NetworkInfo) intent.getParcelableExtra(ConnectivityManager.EXTRA_NETWORK_INFO); } if (netInfo == null || netInfo.isAvailable() == false) { DebugLog.d(TAG, "getCurNetworkInfo() netInfo is null line1383"); if (mbNetworIsConnect != false) { mbNetworIsConnect = false; reloadUrl = GameInfo.getErrorUrl(); reload(reloadUrl); } Utils.setNetworkType(Constants.NETWORKTYPE_NONE); return; } netType = netInfo.getType(); netSubtype = netInfo.getSubtype(); isConnected = netInfo.isConnected(); DebugLog.e(TAG, "======processNetworkType nettype = " + netType + ",netSubtype = " + netSubtype + ",isConnect = " + isConnected); switch (netType) { case ConnectivityManager.TYPE_MOBILE_SUPL: case ConnectivityManager.TYPE_MOBILE_MMS: case ConnectivityManager.TYPE_MOBILE_HIPRI: case ConnectivityManager.TYPE_MOBILE_DUN: case ConnectivityManager.TYPE_MOBILE: DebugLog.d(TAG, "processNetworkType ConnectivityManager.TYPE_MOBILE netSubtype=" + netSubtype); if (netSubtype == TelephonyManager.NETWORK_TYPE_LTE) {//4 DebugLog.d(TAG, "processNetworkType ConnectivityManager.TYPE_MOBILE 4G"); networkType = Constants.NETWORKTYPE_LTE; } else {//3 DebugLog.d(TAG, "processNetworkType ConnectivityManager.TYPE_MOBILE 3G"); networkType = Constants.NETWORKTYPE_3G; } break; case ConnectivityManager.TYPE_WIFI: DebugLog.d(TAG, "processNetworkType ConnectivityManager.TYPE_WIFI"); networkType = Constants.NETWORKTYPE_WIFI; break; case ConnectivityManager.TYPE_ETHERNET: DebugLog.d(TAG, "processNetworkType ConnectivityManager.TYPE_ETHERNET"); networkType = Constants.NETWORKTYPE_ETHERNET; break; default: DebugLog.d(TAG, "other network status"); networkType = Constants.NETWORKTYPE_OTHERS; break; } DebugLog.e(TAG, "======processNetworkType nettype = " + netType + ",netSubtype = " + netSubtype + ",isConnect = " + isConnected + ",mbNetworIsConnect = " + mbNetworIsConnect); if (isConnected) { reloadUrl = Utils.checkUrl(GameInfo.DEFAULT_URL); Utils.setNetworkType(networkType); // Utils.setNetworkType(Constants.NETWORKTYPE_WIFI);//temp change } else { reloadUrl = GameInfo.getErrorUrl(); Utils.setNetworkType(Constants.NETWORKTYPE_NONE); } // if((networkType == Constants.NETWORKTYPE_WIFI || networkType == Constants.NETWORKTYPE_LTE) && mbNetworIsConnect != isConnected){ if (mbNetworIsConnect != isConnected) { mbNetworIsConnect = isConnected; reload(reloadUrl); DebugLog.d(TAG, "Notify reload finish"); } }
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 w w . ja va 2 s . c o m*/ str += " detected"; log(str, "v"); } return newState; }
From source file:com.chen.emailsync.SyncManager.java
/** * Taken from ConnectivityManager using public constants *///from w w w. j ava2s. c o m public static boolean isNetworkTypeMobile(int networkType) { switch (networkType) { case ConnectivityManager.TYPE_MOBILE: case ConnectivityManager.TYPE_MOBILE_MMS: case ConnectivityManager.TYPE_MOBILE_SUPL: case ConnectivityManager.TYPE_MOBILE_DUN: case ConnectivityManager.TYPE_MOBILE_HIPRI: return true; default: return false; } }
From source file:com.ferdi2005.secondgram.voip.VoIPService.java
private int getStatsNetworkType() { int netType = StatsController.TYPE_WIFI; if (lastNetInfo != null) { if (lastNetInfo.getType() == ConnectivityManager.TYPE_MOBILE) netType = lastNetInfo.isRoaming() ? StatsController.TYPE_ROAMING : StatsController.TYPE_MOBILE; }/*from w ww .ja va2s. c o m*/ return netType; }
From source file:com.sonetel.ui.dialpad.DialerFragment.java
protected boolean isInternetAvail(Context context) { connectivityManager = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE); NetworkInfo ni = connectivityManager.getActiveNetworkInfo(); if (ni != null && ni.getType() == ConnectivityManager.TYPE_WIFI) { Log.d(THIS_FILE, "Wifi state is now " + ni.getState().name()); if (ni.getState() == NetworkInfo.State.CONNECTED) { return true; }/*from w w w.j a v a 2 s . c o m*/ } if (ni != null && ni.getType() == ConnectivityManager.TYPE_MOBILE) { // Any mobile network connected if (ni.getState() == NetworkInfo.State.CONNECTED) { int subType = ni.getSubtype(); // 3G (or better) if (subType >= TelephonyManager.NETWORK_TYPE_UMTS) { return true; } // GPRS (or unknown) if (subType == TelephonyManager.NETWORK_TYPE_GPRS || subType == TelephonyManager.NETWORK_TYPE_UNKNOWN) { return true; } // EDGE if (subType == TelephonyManager.NETWORK_TYPE_EDGE) { return true; } } } if (ni != null && ni.getType() != ConnectivityManager.TYPE_MOBILE && ni.getType() != ConnectivityManager.TYPE_WIFI) { if (ni.getState() == NetworkInfo.State.CONNECTED) { return true; } } return false; }
From source file:dev.ukanth.ufirewall.Api.java
public static boolean isMobileNetworkSupported(final Context ctx) { boolean hasMobileData = true; ConnectivityManager cm = (ConnectivityManager) ctx.getSystemService(Context.CONNECTIVITY_SERVICE); if (cm != null) { if (cm.getNetworkInfo(ConnectivityManager.TYPE_MOBILE) == null) { hasMobileData = false;//from ww w.ja va 2s.c o m } } return hasMobileData; }