Java Code Examples for android.telephony.TelephonyManager#NETWORK_TYPE_EVDO_B
The following examples show how to use
android.telephony.TelephonyManager#NETWORK_TYPE_EVDO_B .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: CellBackendHelper.java From android_external_UnifiedNlpApi with Apache License 2.0 | 6 votes |
private static Cell.CellType getCellType(int networkType) { switch (networkType) { case TelephonyManager.NETWORK_TYPE_GPRS: case TelephonyManager.NETWORK_TYPE_EDGE: return Cell.CellType.GSM; case TelephonyManager.NETWORK_TYPE_UMTS: case TelephonyManager.NETWORK_TYPE_HSDPA: case TelephonyManager.NETWORK_TYPE_HSUPA: case TelephonyManager.NETWORK_TYPE_HSPA: case TelephonyManager.NETWORK_TYPE_HSPAP: return Cell.CellType.UMTS; case TelephonyManager.NETWORK_TYPE_LTE: return Cell.CellType.LTE; case TelephonyManager.NETWORK_TYPE_EVDO_0: case TelephonyManager.NETWORK_TYPE_EVDO_A: case TelephonyManager.NETWORK_TYPE_EVDO_B: case TelephonyManager.NETWORK_TYPE_1xRTT: case TelephonyManager.NETWORK_TYPE_EHRPD: case TelephonyManager.NETWORK_TYPE_IDEN: return Cell.CellType.CDMA; } return null; }
Example 2
Source File: Network.java From android-common with Apache License 2.0 | 5 votes |
/** * GPRS 2G(2.5) General Packet Radia Service 114kbps * EDGE 2G(2.75G) Enhanced Data Rate for GSM Evolution 384kbps * UMTS 3G WCDMA 联通3G Universal Mobile Telecommunication System 完整的3G移动通信技术标准 * CDMA 2G 电信 Code Division Multiple Access 码分多址 * EVDO_0 3G (EVDO 全程 CDMA2000 1xEV-DO) Evolution - Data Only (Data Optimized) 153.6kps - 2.4mbps 属于3G * EVDO_A 3G 1.8mbps - 3.1mbps 属于3G过渡,3.5G * 1xRTT 2G CDMA2000 1xRTT (RTT - 无线电传输技术) 144kbps 2G的过渡, * HSDPA 3.5G 高速下行分组接入 3.5G WCDMA High Speed Downlink Packet Access 14.4mbps * HSUPA 3.5G High Speed Uplink Packet Access 高速上行链路分组接入 1.4 - 5.8 mbps * HSPA 3G (分HSDPA,HSUPA) High Speed Packet Access * IDEN 2G Integrated Dispatch Enhanced Networks 集成数字增强型网络 (属于2G,来自维基百科) * EVDO_B 3G EV-DO Rev.B 14.7Mbps 下行 3.5G * LTE 4G Long Term Evolution FDD-LTE 和 TDD-LTE , 3G过渡,升级版 LTE Advanced 才是4G * EHRPD 3G CDMA2000向LTE 4G的中间产物 Evolved High Rate Packet Data HRPD的升级 * HSPAP 3G HSPAP 比 HSDPA 快些 * * @return {@link NetWorkType} */ public static NetWorkType getNetworkType(Context context) { int type = getConnectedTypeINT(context); switch (type) { case ConnectivityManager.TYPE_WIFI: return NetWorkType.Wifi; case ConnectivityManager.TYPE_MOBILE: case ConnectivityManager.TYPE_MOBILE_DUN: case ConnectivityManager.TYPE_MOBILE_HIPRI: case ConnectivityManager.TYPE_MOBILE_MMS: case ConnectivityManager.TYPE_MOBILE_SUPL: int teleType = getTelephonyManager(context).getNetworkType(); switch (teleType) { case TelephonyManager.NETWORK_TYPE_GPRS: case TelephonyManager.NETWORK_TYPE_EDGE: case TelephonyManager.NETWORK_TYPE_CDMA: case TelephonyManager.NETWORK_TYPE_1xRTT: case TelephonyManager.NETWORK_TYPE_IDEN: return NetWorkType.Net2G; case TelephonyManager.NETWORK_TYPE_UMTS: case TelephonyManager.NETWORK_TYPE_EVDO_0: case TelephonyManager.NETWORK_TYPE_EVDO_A: case TelephonyManager.NETWORK_TYPE_HSDPA: case TelephonyManager.NETWORK_TYPE_HSUPA: case TelephonyManager.NETWORK_TYPE_HSPA: case TelephonyManager.NETWORK_TYPE_EVDO_B: case TelephonyManager.NETWORK_TYPE_EHRPD: case TelephonyManager.NETWORK_TYPE_HSPAP: return NetWorkType.Net3G; case TelephonyManager.NETWORK_TYPE_LTE: return NetWorkType.Net4G; default: return NetWorkType.UnKnown; } default: return NetWorkType.UnKnown; } }
Example 3
Source File: AppNetworkMgr.java From AndroidWallet with GNU General Public License v3.0 | 5 votes |
/** * 判断当前网络的具体类型是否是EDGE * * @param context 上下文 * @return false:当前网络的具体类型是否是EVDO_B。false:当前没有网络连接或者具体类型不是EVDO_B */ @TargetApi(Build.VERSION_CODES.GINGERBREAD) public static boolean isEVDO_BBySubtype(Context context) { if (Build.VERSION.SDK_INT < Build.VERSION_CODES.GINGERBREAD) { return false; } else { return getCurrentNetworkSubtype(context) == TelephonyManager.NETWORK_TYPE_EVDO_B; } }
Example 4
Source File: PicassoExecutorService.java From DoraemonKit with Apache License 2.0 | 5 votes |
void adjustThreadCount(NetworkInfo info) { if (info == null || !info.isConnectedOrConnecting()) { setThreadCount(DEFAULT_THREAD_COUNT); return; } switch (info.getType()) { case ConnectivityManager.TYPE_WIFI: case ConnectivityManager.TYPE_WIMAX: case ConnectivityManager.TYPE_ETHERNET: setThreadCount(4); break; case ConnectivityManager.TYPE_MOBILE: switch (info.getSubtype()) { case TelephonyManager.NETWORK_TYPE_LTE: // 4G case TelephonyManager.NETWORK_TYPE_HSPAP: case TelephonyManager.NETWORK_TYPE_EHRPD: setThreadCount(3); break; case TelephonyManager.NETWORK_TYPE_UMTS: // 3G case TelephonyManager.NETWORK_TYPE_CDMA: case TelephonyManager.NETWORK_TYPE_EVDO_0: case TelephonyManager.NETWORK_TYPE_EVDO_A: case TelephonyManager.NETWORK_TYPE_EVDO_B: setThreadCount(2); break; case TelephonyManager.NETWORK_TYPE_GPRS: // 2G case TelephonyManager.NETWORK_TYPE_EDGE: setThreadCount(1); break; default: setThreadCount(DEFAULT_THREAD_COUNT); } break; default: setThreadCount(DEFAULT_THREAD_COUNT); } }
Example 5
Source File: AgentWebUtils.java From AgentWeb with Apache License 2.0 | 5 votes |
public static int checkNetworkType(Context context) { int netType = 0; //连接管理对象 ConnectivityManager manager = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE); //获取NetworkInfo对象 @SuppressLint("MissingPermission") NetworkInfo networkInfo = manager.getActiveNetworkInfo(); if (networkInfo == null) { return netType; } switch (networkInfo.getType()) { case ConnectivityManager.TYPE_WIFI: case ConnectivityManager.TYPE_WIMAX: case ConnectivityManager.TYPE_ETHERNET: return 1; case ConnectivityManager.TYPE_MOBILE: switch (networkInfo.getSubtype()) { case TelephonyManager.NETWORK_TYPE_LTE: // 4G case TelephonyManager.NETWORK_TYPE_HSPAP: case TelephonyManager.NETWORK_TYPE_EHRPD: return 2; case TelephonyManager.NETWORK_TYPE_UMTS: // 3G case TelephonyManager.NETWORK_TYPE_CDMA: case TelephonyManager.NETWORK_TYPE_EVDO_0: case TelephonyManager.NETWORK_TYPE_EVDO_A: case TelephonyManager.NETWORK_TYPE_EVDO_B: return 3; case TelephonyManager.NETWORK_TYPE_GPRS: // 2G case TelephonyManager.NETWORK_TYPE_EDGE: return 4; default: return netType; } default: return netType; } }
Example 6
Source File: NetworkUtil.java From RxZhihuDaily with MIT License | 5 votes |
private static String getNetworkTypeNameInMobile(int type) { switch (type) { case TelephonyManager.NETWORK_TYPE_GPRS: return "GPRS"; case TelephonyManager.NETWORK_TYPE_EDGE: return "EDGE"; case TelephonyManager.NETWORK_TYPE_UMTS: return "UMTS"; case TelephonyManager.NETWORK_TYPE_HSDPA: return "HSDPA"; case TelephonyManager.NETWORK_TYPE_HSUPA: return "HSUPA"; case TelephonyManager.NETWORK_TYPE_HSPA: return "HSPA"; case TelephonyManager.NETWORK_TYPE_CDMA: return "CDMA"; case TelephonyManager.NETWORK_TYPE_EVDO_0: return "CDMA - EvDo rev. 0"; case TelephonyManager.NETWORK_TYPE_EVDO_A: return "CDMA - EvDo rev. A"; case TelephonyManager.NETWORK_TYPE_EVDO_B: return "CDMA - EvDo rev. B"; case TelephonyManager.NETWORK_TYPE_1xRTT: return "CDMA - 1xRTT"; case TelephonyManager.NETWORK_TYPE_LTE: return "LTE"; case TelephonyManager.NETWORK_TYPE_EHRPD: return "CDMA - eHRPD"; case TelephonyManager.NETWORK_TYPE_IDEN: return "iDEN"; case TelephonyManager.NETWORK_TYPE_HSPAP: return "HSPA+"; default: return "UNKNOWN"; } }
Example 7
Source File: DeviceInfo.java From Cangol-appcore with Apache License 2.0 | 5 votes |
public static int getNetworkClass(Context context) { int networkType= getNetworkType(context); if (networkType == NETWORK_TYPE_WIFI) { return NETWORK_CLASS_WIFI; } else if (networkType == NETWORK_TYPE_UNAVAILABLE) { return NETWORK_CLASS_UNAVAILABLE; }else{ switch (networkType) { case TelephonyManager.NETWORK_TYPE_GPRS: case TelephonyManager.NETWORK_TYPE_EDGE: case TelephonyManager.NETWORK_TYPE_CDMA: case TelephonyManager.NETWORK_TYPE_1xRTT: case TelephonyManager.NETWORK_TYPE_IDEN: return NETWORK_CLASS_2G; case TelephonyManager.NETWORK_TYPE_UMTS: case TelephonyManager.NETWORK_TYPE_EVDO_0: case TelephonyManager.NETWORK_TYPE_EVDO_A: case TelephonyManager.NETWORK_TYPE_HSDPA: case TelephonyManager.NETWORK_TYPE_HSUPA: case TelephonyManager.NETWORK_TYPE_HSPA: case TelephonyManager.NETWORK_TYPE_EVDO_B: case TelephonyManager.NETWORK_TYPE_EHRPD: case TelephonyManager.NETWORK_TYPE_HSPAP: return NETWORK_CLASS_3G; case TelephonyManager.NETWORK_TYPE_LTE: return NETWORK_CLASS_4G; default: return NETWORK_CLASS_UNKNOWN; } } }
Example 8
Source File: NetworkChangeNotifierAutoDetect.java From cronet with BSD 3-Clause "New" or "Revised" License | 5 votes |
/** * Returns the connection type for the given ConnectivityManager type and subtype. */ @ConnectionType private static int convertToConnectionType(int type, int subtype) { switch (type) { case ConnectivityManager.TYPE_ETHERNET: return ConnectionType.CONNECTION_ETHERNET; case ConnectivityManager.TYPE_WIFI: return ConnectionType.CONNECTION_WIFI; case ConnectivityManager.TYPE_WIMAX: return ConnectionType.CONNECTION_4G; case ConnectivityManager.TYPE_BLUETOOTH: return ConnectionType.CONNECTION_BLUETOOTH; case ConnectivityManager.TYPE_MOBILE: // Use information from TelephonyManager to classify the connection. switch (subtype) { case TelephonyManager.NETWORK_TYPE_GPRS: case TelephonyManager.NETWORK_TYPE_EDGE: case TelephonyManager.NETWORK_TYPE_CDMA: case TelephonyManager.NETWORK_TYPE_1xRTT: case TelephonyManager.NETWORK_TYPE_IDEN: return ConnectionType.CONNECTION_2G; case TelephonyManager.NETWORK_TYPE_UMTS: case TelephonyManager.NETWORK_TYPE_EVDO_0: case TelephonyManager.NETWORK_TYPE_EVDO_A: case TelephonyManager.NETWORK_TYPE_HSDPA: case TelephonyManager.NETWORK_TYPE_HSUPA: case TelephonyManager.NETWORK_TYPE_HSPA: case TelephonyManager.NETWORK_TYPE_EVDO_B: case TelephonyManager.NETWORK_TYPE_EHRPD: case TelephonyManager.NETWORK_TYPE_HSPAP: return ConnectionType.CONNECTION_3G; case TelephonyManager.NETWORK_TYPE_LTE: return ConnectionType.CONNECTION_4G; default: return ConnectionType.CONNECTION_UNKNOWN; } default: return ConnectionType.CONNECTION_UNKNOWN; } }
Example 9
Source File: VenvyDeviceUtil.java From VideoOS-Android-SDK with GNU General Public License v3.0 | 4 votes |
public static int getNetWorkType(Context context) { int strNetworkType = 0; ConnectivityManager connectivityManager = (ConnectivityManager) context.getSystemService (Context.CONNECTIVITY_SERVICE); NetworkInfo networkInfo = connectivityManager.getActiveNetworkInfo(); if (networkInfo != null && networkInfo.isConnected()) { if (networkInfo.getType() == ConnectivityManager.TYPE_WIFI) { strNetworkType = 1; } else if (networkInfo.getType() == ConnectivityManager.TYPE_MOBILE) { String _strSubTypeName = networkInfo.getSubtypeName(); VenvyLog.i("cocos2d-x", "Network getSubtypeName : " + _strSubTypeName); // TD-SCDMA networkType is 17 int networkType = networkInfo.getSubtype(); switch (networkType) { case TelephonyManager.NETWORK_TYPE_GPRS: case TelephonyManager.NETWORK_TYPE_EDGE: case TelephonyManager.NETWORK_TYPE_CDMA: case TelephonyManager.NETWORK_TYPE_1xRTT: case TelephonyManager.NETWORK_TYPE_IDEN: //api<8 : replace by 11 case TelephonyManager.NETWORK_TYPE_GSM: // api<25: replace by 16 strNetworkType = 2; break; case TelephonyManager.NETWORK_TYPE_UMTS: case TelephonyManager.NETWORK_TYPE_EVDO_0: case TelephonyManager.NETWORK_TYPE_EVDO_A: case TelephonyManager.NETWORK_TYPE_HSDPA: case TelephonyManager.NETWORK_TYPE_HSUPA: case TelephonyManager.NETWORK_TYPE_HSPA: case TelephonyManager.NETWORK_TYPE_EVDO_B: // api< 9: replace by 12 case TelephonyManager.NETWORK_TYPE_EHRPD: // api<11: replace by 14 case TelephonyManager.NETWORK_TYPE_HSPAP: // api<13: replace by 15 case TelephonyManager.NETWORK_TYPE_TD_SCDMA: // api<25: replace by 17 strNetworkType = 3; break; case TelephonyManager.NETWORK_TYPE_LTE: // api<11: replace by 13 case TelephonyManager.NETWORK_TYPE_IWLAN: // api<25: replace by 18 strNetworkType = 4; break; case TelephonyManager.NETWORK_TYPE_NR:// api<29: replace by 20 strNetworkType = 5; break; } } } return strNetworkType; }
Example 10
Source File: NetworkUtils.java From MyUtil with Apache License 2.0 | 4 votes |
/** * 获取当前的网络状态 * @param context 全局context * @return * 没有网络-NO * WIFI网络-WIFI * 4G网络-4G * 3G网络-3G * 2G网络-2G * 未知-Unknown */ public static String getAPNType(Context context) { ConnectivityManager manager = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE); NetworkInfo networkInfo = manager.getActiveNetworkInfo(); if (networkInfo == null) { //无网络 return "NO"; } int nType = networkInfo.getType(); if (nType == ConnectivityManager.TYPE_WIFI) { //wifi return "WIFI"; } else if (nType == ConnectivityManager.TYPE_MOBILE) { int nSubType = networkInfo.getSubtype(); TelephonyManager telephonyManager = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE); if (nSubType == TelephonyManager.NETWORK_TYPE_LTE && !telephonyManager.isNetworkRoaming()) { return "4G"; } else if (nSubType == TelephonyManager.NETWORK_TYPE_UMTS || nSubType == TelephonyManager.NETWORK_TYPE_EVDO_0 || nSubType == TelephonyManager.NETWORK_TYPE_EVDO_A || nSubType == TelephonyManager.NETWORK_TYPE_HSDPA || nSubType == TelephonyManager.NETWORK_TYPE_HSUPA || nSubType == TelephonyManager.NETWORK_TYPE_HSPA || nSubType == TelephonyManager.NETWORK_TYPE_EVDO_B || nSubType == TelephonyManager.NETWORK_TYPE_EHRPD || nSubType == TelephonyManager.NETWORK_TYPE_HSPAP && !telephonyManager.isNetworkRoaming()) { return "3G"; } else if (nSubType == TelephonyManager.NETWORK_TYPE_GPRS || nSubType == TelephonyManager.NETWORK_TYPE_EDGE || nSubType == TelephonyManager.NETWORK_TYPE_CDMA || nSubType == TelephonyManager.NETWORK_TYPE_1xRTT || nSubType == TelephonyManager.NETWORK_TYPE_IDEN && !telephonyManager.isNetworkRoaming()) { return "2G"; } else { return "Unknown"; } } return "Unknown"; }
Example 11
Source File: NetworkConnUtil.java From RairDemo with Apache License 2.0 | 4 votes |
/** * 判断手机当前网络类型是否是快速网络类型 * * @param type * @param subType * @return */ public static boolean isConnectionFast(int type, int subType) { if (type == ConnectivityManager.TYPE_WIFI) { System.out.println("CONNECTED VIA WIFI"); return true; } else if (type == ConnectivityManager.TYPE_MOBILE) { switch (subType) { case TelephonyManager.NETWORK_TYPE_1xRTT: return false; // ~ 50-100 kbps case TelephonyManager.NETWORK_TYPE_CDMA: return false; // ~ 14-64 kbps case TelephonyManager.NETWORK_TYPE_EDGE: return false; // ~ 50-100 kbps case TelephonyManager.NETWORK_TYPE_GPRS: return false; // ~ 100 kbps case TelephonyManager.NETWORK_TYPE_IDEN: return false; // ~25 kbps case TelephonyManager.NETWORK_TYPE_EVDO_0: return true; // ~ 400-1000 kbps case TelephonyManager.NETWORK_TYPE_EVDO_A: return true; // ~ 600-1400 kbps case TelephonyManager.NETWORK_TYPE_HSDPA: return true; // ~ 2-14 Mbps case TelephonyManager.NETWORK_TYPE_HSPA: return true; // ~ 700-1700 kbps case TelephonyManager.NETWORK_TYPE_HSUPA: return true; // ~ 1-23 Mbps case TelephonyManager.NETWORK_TYPE_UMTS: return true; // ~ 400-7000 kbps // NOT AVAILABLE YET IN API LEVEL 7 case TelephonyManager.NETWORK_TYPE_EHRPD: return true; // ~ 1-2 Mbps case TelephonyManager.NETWORK_TYPE_EVDO_B: return true; // ~ 5 Mbps case TelephonyManager.NETWORK_TYPE_HSPAP: return true; // ~ 10-20 Mbps case TelephonyManager.NETWORK_TYPE_LTE: return true; // ~ 10+ Mbps // Unknown case TelephonyManager.NETWORK_TYPE_UNKNOWN: return false; default: return false; } } else { return false; } }
Example 12
Source File: Util.java From NMSAlphabetAndroidApp with MIT License | 4 votes |
private static boolean isConnectionFast(int type, int subType){ if(type == ConnectivityManager.TYPE_WIFI){ return true; } else if (type == ConnectivityManager.TYPE_MOBILE){ switch (subType){ case TelephonyManager.NETWORK_TYPE_1xRTT: return false; // ~ 50-100 kbps case TelephonyManager.NETWORK_TYPE_CDMA: return false; // ~ 14-64 kbps case TelephonyManager.NETWORK_TYPE_EDGE: return false; // ~ 50-100 kbps case TelephonyManager.NETWORK_TYPE_EVDO_0: return true; // ~ 400-1000 kbps case TelephonyManager.NETWORK_TYPE_EVDO_A: return true; // ~ 600-1400 kbps case TelephonyManager.NETWORK_TYPE_GPRS: return false; // ~ 100 kbps case TelephonyManager.NETWORK_TYPE_HSDPA: return true; // ~ 2-14 Mbps case TelephonyManager.NETWORK_TYPE_HSPA: return true; // ~ 700-1700 kbps case TelephonyManager.NETWORK_TYPE_HSUPA: return true; // ~ 1-23 Mbps case TelephonyManager.NETWORK_TYPE_UMTS: return true; // ~ 400-7000 kbps case TelephonyManager.NETWORK_TYPE_EHRPD: return true; // ~ 1-2 Mbps case TelephonyManager.NETWORK_TYPE_EVDO_B: return true; // ~ 5 Mbps case TelephonyManager.NETWORK_TYPE_HSPAP: return true; // ~ 10-20 Mbps case TelephonyManager.NETWORK_TYPE_IDEN: return false; // ~25 kbps case TelephonyManager.NETWORK_TYPE_LTE: return true; // ~ 10+ Mbps case TelephonyManager.NETWORK_TYPE_UNKNOWN: default: return false; } } else { return false; } }
Example 13
Source File: NetworkUtils.java From BookReader with Apache License 2.0 | 4 votes |
/** * 获取当前的网络类型(WIFI,2G,3G,4G) * <p>需添加权限 {@code <uses-permission android:name="android.permission * .ACCESS_NETWORK_STATE"/>}</p> * * @param context 上下文 * @return 网络类型 * <ul> * <li>{@link #NETWORK_WIFI } = 1;</li> * <li>{@link #NETWORK_4G } = 4;</li> * <li>{@link #NETWORK_3G } = 3;</li> * <li>{@link #NETWORK_2G } = 2;</li> * <li>{@link #NETWORK_UNKNOWN} = 5;</li> * <li>{@link #NETWORK_NO } = -1;</li> * </ul> */ public static int getNetWorkType(Context context) { int netType = NETWORK_NO; NetworkInfo info = getActiveNetworkInfo(context); if (info != null && info.isAvailable()) { if (info.getType() == ConnectivityManager.TYPE_WIFI) { netType = NETWORK_WIFI; } else if (info.getType() == ConnectivityManager.TYPE_MOBILE) { switch (info.getSubtype()) { case NETWORK_TYPE_GSM: case TelephonyManager.NETWORK_TYPE_GPRS: case TelephonyManager.NETWORK_TYPE_CDMA: case TelephonyManager.NETWORK_TYPE_EDGE: case TelephonyManager.NETWORK_TYPE_1xRTT: case TelephonyManager.NETWORK_TYPE_IDEN: netType = NETWORK_2G; break; case NETWORK_TYPE_TD_SCDMA: case TelephonyManager.NETWORK_TYPE_EVDO_A: case TelephonyManager.NETWORK_TYPE_UMTS: case TelephonyManager.NETWORK_TYPE_EVDO_0: case TelephonyManager.NETWORK_TYPE_HSDPA: case TelephonyManager.NETWORK_TYPE_HSUPA: case TelephonyManager.NETWORK_TYPE_HSPA: case TelephonyManager.NETWORK_TYPE_EVDO_B: case TelephonyManager.NETWORK_TYPE_EHRPD: case TelephonyManager.NETWORK_TYPE_HSPAP: netType = NETWORK_3G; break; case NETWORK_TYPE_IWLAN: case TelephonyManager.NETWORK_TYPE_LTE: netType = NETWORK_4G; break; default: String subtypeName = info.getSubtypeName(); if (subtypeName.equalsIgnoreCase("TD-SCDMA") || subtypeName.equalsIgnoreCase("WCDMA") || subtypeName.equalsIgnoreCase("CDMA2000")) { netType = NETWORK_3G; } else { netType = NETWORK_UNKNOWN; } break; } } else { netType = NETWORK_UNKNOWN; } } return netType; }
Example 14
Source File: HomeActivity.java From apollo-DuerOS with Apache License 2.0 | 4 votes |
private void updateNetworkStatus() { NetworkInfo info = mConnectivityManager.getActiveNetworkInfo(); if (info != null) { LogUtil.i(TAG, "network type name: " + info.getTypeName()); LogUtil.i(TAG, "network subType name: " + info.getSubtypeName()); if (info.getType() == ConnectivityManager.TYPE_WIFI) { if (mWifiManager.getConnectionInfo() != null) { int rssi = mWifiManager.getConnectionInfo().getRssi(); int level = WifiManager.calculateSignalLevel(rssi, 4); switch (level) { case 0: mNetworkImg.setImageResource(R.drawable.ic_wifi4); break; case 1: mNetworkImg.setImageResource(R.drawable.ic_wifi3); break; case 2: mNetworkImg.setImageResource(R.drawable.ic_wifi2); break; case 3: mNetworkImg.setImageResource(R.drawable.ic_wifi); break; default: break; } LogUtil.i(TAG, "Wifi Level " + level); } } else if (info.getType() == ConnectivityManager.TYPE_MOBILE) { switch (info.getSubtype()) { case TelephonyManager.NETWORK_TYPE_GPRS: case TelephonyManager.NETWORK_TYPE_EDGE: case TelephonyManager.NETWORK_TYPE_CDMA: case TelephonyManager.NETWORK_TYPE_1xRTT: case TelephonyManager.NETWORK_TYPE_IDEN: mNetworkImg.setImageResource(R.drawable.ic_net_e); break; case TelephonyManager.NETWORK_TYPE_UMTS: case TelephonyManager.NETWORK_TYPE_EVDO_0: case TelephonyManager.NETWORK_TYPE_EVDO_A: case TelephonyManager.NETWORK_TYPE_HSDPA: case TelephonyManager.NETWORK_TYPE_HSUPA: case TelephonyManager.NETWORK_TYPE_HSPA: case TelephonyManager.NETWORK_TYPE_EVDO_B: case TelephonyManager.NETWORK_TYPE_EHRPD: case TelephonyManager.NETWORK_TYPE_HSPAP: mNetworkImg.setImageResource(R.drawable.ic_net_3g); break; case TelephonyManager.NETWORK_TYPE_LTE: mNetworkImg.setImageResource(R.drawable.ic_net_4g); break; default: mNetworkImg.setImageResource(R.drawable.ic_net_none); break; } } } else { mNetworkImg.setImageResource(R.drawable.ic_net_none); } }
Example 15
Source File: NetworkChangeNotifierAutoDetect.java From android-chromium with BSD 2-Clause "Simplified" License | 4 votes |
public int getCurrentConnectionType() { // Track exactly what type of connection we have. if (!mConnectivityManagerDelegate.activeNetworkExists() || !mConnectivityManagerDelegate.isConnected()) { return NetworkChangeNotifier.CONNECTION_NONE; } switch (mConnectivityManagerDelegate.getNetworkType()) { case ConnectivityManager.TYPE_ETHERNET: return NetworkChangeNotifier.CONNECTION_ETHERNET; case ConnectivityManager.TYPE_WIFI: return NetworkChangeNotifier.CONNECTION_WIFI; case ConnectivityManager.TYPE_WIMAX: return NetworkChangeNotifier.CONNECTION_4G; case ConnectivityManager.TYPE_MOBILE: // Use information from TelephonyManager to classify the connection. switch (mConnectivityManagerDelegate.getNetworkSubtype()) { case TelephonyManager.NETWORK_TYPE_GPRS: case TelephonyManager.NETWORK_TYPE_EDGE: case TelephonyManager.NETWORK_TYPE_CDMA: case TelephonyManager.NETWORK_TYPE_1xRTT: case TelephonyManager.NETWORK_TYPE_IDEN: return NetworkChangeNotifier.CONNECTION_2G; case TelephonyManager.NETWORK_TYPE_UMTS: case TelephonyManager.NETWORK_TYPE_EVDO_0: case TelephonyManager.NETWORK_TYPE_EVDO_A: case TelephonyManager.NETWORK_TYPE_HSDPA: case TelephonyManager.NETWORK_TYPE_HSUPA: case TelephonyManager.NETWORK_TYPE_HSPA: case TelephonyManager.NETWORK_TYPE_EVDO_B: case TelephonyManager.NETWORK_TYPE_EHRPD: case TelephonyManager.NETWORK_TYPE_HSPAP: return NetworkChangeNotifier.CONNECTION_3G; case TelephonyManager.NETWORK_TYPE_LTE: return NetworkChangeNotifier.CONNECTION_4G; default: return NetworkChangeNotifier.CONNECTION_UNKNOWN; } default: return NetworkChangeNotifier.CONNECTION_UNKNOWN; } }
Example 16
Source File: NetworkChangeNotifierAutoDetect.java From 365browser with Apache License 2.0 | 4 votes |
/** * Returns the connection subtype for the given NetworkState. */ public int getConnectionSubtype() { if (!isConnected()) { return ConnectionSubtype.SUBTYPE_NONE; } switch (getNetworkType()) { case ConnectivityManager.TYPE_ETHERNET: case ConnectivityManager.TYPE_WIFI: case ConnectivityManager.TYPE_WIMAX: case ConnectivityManager.TYPE_BLUETOOTH: return ConnectionSubtype.SUBTYPE_UNKNOWN; case ConnectivityManager.TYPE_MOBILE: // Use information from TelephonyManager to classify the connection. switch (getNetworkSubType()) { case TelephonyManager.NETWORK_TYPE_GPRS: return ConnectionSubtype.SUBTYPE_GPRS; case TelephonyManager.NETWORK_TYPE_EDGE: return ConnectionSubtype.SUBTYPE_EDGE; case TelephonyManager.NETWORK_TYPE_CDMA: return ConnectionSubtype.SUBTYPE_CDMA; case TelephonyManager.NETWORK_TYPE_1xRTT: return ConnectionSubtype.SUBTYPE_1XRTT; case TelephonyManager.NETWORK_TYPE_IDEN: return ConnectionSubtype.SUBTYPE_IDEN; case TelephonyManager.NETWORK_TYPE_UMTS: return ConnectionSubtype.SUBTYPE_UMTS; case TelephonyManager.NETWORK_TYPE_EVDO_0: return ConnectionSubtype.SUBTYPE_EVDO_REV_0; case TelephonyManager.NETWORK_TYPE_EVDO_A: return ConnectionSubtype.SUBTYPE_EVDO_REV_A; case TelephonyManager.NETWORK_TYPE_HSDPA: return ConnectionSubtype.SUBTYPE_HSDPA; case TelephonyManager.NETWORK_TYPE_HSUPA: return ConnectionSubtype.SUBTYPE_HSUPA; case TelephonyManager.NETWORK_TYPE_HSPA: return ConnectionSubtype.SUBTYPE_HSPA; case TelephonyManager.NETWORK_TYPE_EVDO_B: return ConnectionSubtype.SUBTYPE_EVDO_REV_B; case TelephonyManager.NETWORK_TYPE_EHRPD: return ConnectionSubtype.SUBTYPE_EHRPD; case TelephonyManager.NETWORK_TYPE_HSPAP: return ConnectionSubtype.SUBTYPE_HSPAP; case TelephonyManager.NETWORK_TYPE_LTE: return ConnectionSubtype.SUBTYPE_LTE; default: return ConnectionSubtype.SUBTYPE_UNKNOWN; } default: return ConnectionSubtype.SUBTYPE_UNKNOWN; } }
Example 17
Source File: Net.java From HttpInfo with Apache License 2.0 | 4 votes |
public static String networkTypeMobile(Context context) { TelephonyManager telephonyManager = (TelephonyManager) context.getSystemService(Context .TELEPHONY_SERVICE); if (telephonyManager == null || !hasSimCard(context)) { return "Other"; } int networkType = telephonyManager.getNetworkType(); switch (networkType) { case TelephonyManager.NETWORK_TYPE_GPRS: return "2G_GPRS"; case TelephonyManager.NETWORK_TYPE_EDGE: return "2G_EDGE"; case TelephonyManager.NETWORK_TYPE_CDMA: return "2G_CDMA"; case TelephonyManager.NETWORK_TYPE_1xRTT: return "2G_1xRTT"; case TelephonyManager.NETWORK_TYPE_IDEN: return "2G_IDEN"; case TelephonyManager.NETWORK_TYPE_UMTS: return "3G_UMTS"; case TelephonyManager.NETWORK_TYPE_EVDO_0: return "3G_EVDO_0"; case TelephonyManager.NETWORK_TYPE_EVDO_A: return "3G_EVDO_A"; case TelephonyManager.NETWORK_TYPE_HSDPA: return "3G_HSDPA"; case TelephonyManager.NETWORK_TYPE_HSUPA: return "3G_HSUPA"; case TelephonyManager.NETWORK_TYPE_HSPA: return "3G_HSPA"; case TelephonyManager.NETWORK_TYPE_EVDO_B: return "3G_EVDO_B"; case TelephonyManager.NETWORK_TYPE_EHRPD: return "3G_EHRPD"; case TelephonyManager.NETWORK_TYPE_HSPAP: return "3G_SHPAP"; case TelephonyManager.NETWORK_TYPE_LTE: return "4G_LTE"; default: return "Other"; } }
Example 18
Source File: HomeActivity.java From apollo-DuerOS with Apache License 2.0 | 4 votes |
private void updateNetworkStatus() { NetworkInfo info = mConnectivityManager.getActiveNetworkInfo(); if (info != null) { LogUtil.i(TAG, "getTypeName(): " + info.getTypeName()); LogUtil.i(TAG, "getSubtypeName(): " + info.getSubtypeName()); if (info.getType() == ConnectivityManager.TYPE_WIFI) { if (mWifiManager.getConnectionInfo() != null) { int rssi = mWifiManager.getConnectionInfo().getRssi(); int level = WifiManager.calculateSignalLevel(rssi, 4); switch (level) { case 0: mNetworkImg.setImageResource(R.drawable.wifi4); break; case 1: mNetworkImg.setImageResource(R.drawable.wifi3); break; case 2: mNetworkImg.setImageResource(R.drawable.wifi2); break; case 3: mNetworkImg.setImageResource(R.drawable.wifi); break; default: break; } LogUtil.i(TAG, "Wifi Level " + level); } } else if (info.getType() == ConnectivityManager.TYPE_MOBILE) { switch (info.getSubtype()) { case TelephonyManager.NETWORK_TYPE_GPRS: case TelephonyManager.NETWORK_TYPE_EDGE: case TelephonyManager.NETWORK_TYPE_CDMA: case TelephonyManager.NETWORK_TYPE_1xRTT: case TelephonyManager.NETWORK_TYPE_IDEN: mNetworkImg.setImageResource(R.drawable.net_e); break; case TelephonyManager.NETWORK_TYPE_UMTS: case TelephonyManager.NETWORK_TYPE_EVDO_0: case TelephonyManager.NETWORK_TYPE_EVDO_A: case TelephonyManager.NETWORK_TYPE_HSDPA: case TelephonyManager.NETWORK_TYPE_HSUPA: case TelephonyManager.NETWORK_TYPE_HSPA: case TelephonyManager.NETWORK_TYPE_EVDO_B: case TelephonyManager.NETWORK_TYPE_EHRPD: case TelephonyManager.NETWORK_TYPE_HSPAP: mNetworkImg.setImageResource(R.drawable.net_3g); break; case TelephonyManager.NETWORK_TYPE_LTE: mNetworkImg.setImageResource(R.drawable.net_4g); break; default: mNetworkImg.setImageResource(R.drawable.net_none); break; } } } else { mNetworkImg.setImageResource(R.drawable.net_none); } }
Example 19
Source File: ConnectivityUtil.java From MVPAndroidBootstrap with Apache License 2.0 | 4 votes |
/** * Check if the connection is fast * * @param type * @param subType * @return */ public static boolean isConnectionFast(int type, int subType) { if (type == ConnectivityManager.TYPE_WIFI) { return true; } else if (type == ConnectivityManager.TYPE_MOBILE) { switch (subType) { case TelephonyManager.NETWORK_TYPE_1xRTT: return false; // ~ 50-100 kbps case TelephonyManager.NETWORK_TYPE_CDMA: return false; // ~ 14-64 kbps case TelephonyManager.NETWORK_TYPE_EDGE: return false; // ~ 50-100 kbps case TelephonyManager.NETWORK_TYPE_EVDO_0: return true; // ~ 400-1000 kbps case TelephonyManager.NETWORK_TYPE_EVDO_A: return true; // ~ 600-1400 kbps case TelephonyManager.NETWORK_TYPE_GPRS: return false; // ~ 100 kbps case TelephonyManager.NETWORK_TYPE_HSDPA: return true; // ~ 2-14 Mbps case TelephonyManager.NETWORK_TYPE_HSPA: return true; // ~ 700-1700 kbps case TelephonyManager.NETWORK_TYPE_HSUPA: return true; // ~ 1-23 Mbps case TelephonyManager.NETWORK_TYPE_UMTS: return true; // ~ 400-7000 kbps /* * Above API level 7, make sure to set android:targetSdkVersion * to appropriate level to use these */ case TelephonyManager.NETWORK_TYPE_EHRPD: // API level 11 return true; // ~ 1-2 Mbps case TelephonyManager.NETWORK_TYPE_EVDO_B: // API level 9 return true; // ~ 5 Mbps case TelephonyManager.NETWORK_TYPE_HSPAP: // API level 13 return true; // ~ 10-20 Mbps case TelephonyManager.NETWORK_TYPE_IDEN: // API level 8 return false; // ~25 kbps case TelephonyManager.NETWORK_TYPE_LTE: // API level 11 return true; // ~ 10+ Mbps // Unknown case TelephonyManager.NETWORK_TYPE_UNKNOWN: default: return false; } } else { return false; } }
Example 20
Source File: EasyNetworkMod.java From easydeviceinfo with Apache License 2.0 | 4 votes |
/** * Gets network type. * * You need to declare the below permission in the manifest file to use this properly * * <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/> * <uses-permission android:name="android.permission.INTERNET"/> * * @return the network type */ @RequiresPermission(allOf = { Manifest.permission.ACCESS_NETWORK_STATE, Manifest.permission.INTERNET }) @NetworkType public final int getNetworkType() { int result = NetworkType.UNKNOWN; if (PermissionUtil.hasPermission(context, Manifest.permission.ACCESS_NETWORK_STATE)) { ConnectivityManager cm = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE); if (cm != null) { NetworkInfo activeNetwork = cm.getActiveNetworkInfo(); if (activeNetwork == null) { result = NetworkType.UNKNOWN; } else if (activeNetwork.getType() == ConnectivityManager.TYPE_WIFI || activeNetwork.getType() == ConnectivityManager.TYPE_WIMAX) { result = NetworkType.WIFI_WIFIMAX; } else if (activeNetwork.getType() == ConnectivityManager.TYPE_MOBILE) { TelephonyManager manager = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE); if (manager != null && manager.getSimState() == TelephonyManager.SIM_STATE_READY) { switch (manager.getNetworkType()) { // Unknown case TelephonyManager.NETWORK_TYPE_UNKNOWN: result = NetworkType.CELLULAR_UNKNOWN; break; // Cellular Data 2G case TelephonyManager.NETWORK_TYPE_EDGE: case TelephonyManager.NETWORK_TYPE_GPRS: case TelephonyManager.NETWORK_TYPE_CDMA: case TelephonyManager.NETWORK_TYPE_IDEN: case TelephonyManager.NETWORK_TYPE_1xRTT: result = NetworkType.CELLULAR_2G; break; // Cellular Data 3G case TelephonyManager.NETWORK_TYPE_UMTS: 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_0: case TelephonyManager.NETWORK_TYPE_EVDO_A: case TelephonyManager.NETWORK_TYPE_EVDO_B: result = NetworkType.CELLULAR_3G; break; // Cellular Data 4G case TelephonyManager.NETWORK_TYPE_LTE: result = NetworkType.CELLULAR_4G; break; // Cellular Data Unknown Generation default: result = NetworkType.CELLULAR_UNIDENTIFIED_GEN; break; } } } } } return result; }