Java Code Examples for android.telephony.TelephonyManager#NETWORK_TYPE_TD_SCDMA
The following examples show how to use
android.telephony.TelephonyManager#NETWORK_TYPE_TD_SCDMA .
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: NetWorkUtils.java From DevUtils with Apache License 2.0 | 7 votes |
/** * 获取移动网络连接类型 * <pre> * {@link TelephonyManager#getNetworkClass} hide 方法 * </pre> * @param networkType {@link TelephonyManager#getNetworkType} * @return 0 = 未知, 1 = 2G, 2 = 3G, 3 = 4G, 4 = 5G */ public static int getNetworkClass(final int networkType) { switch (networkType) { case TelephonyManager.NETWORK_TYPE_GPRS: case TelephonyManager.NETWORK_TYPE_GSM: case TelephonyManager.NETWORK_TYPE_EDGE: case TelephonyManager.NETWORK_TYPE_CDMA: case TelephonyManager.NETWORK_TYPE_1xRTT: case TelephonyManager.NETWORK_TYPE_IDEN: return 1; 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: case TelephonyManager.NETWORK_TYPE_TD_SCDMA: return 2; case TelephonyManager.NETWORK_TYPE_LTE: case TelephonyManager.NETWORK_TYPE_IWLAN: case 19: // TelephonyManager.NETWORK_TYPE_LTE_CA return 3; case TelephonyManager.NETWORK_TYPE_NR: return 4; default: return 0; } }
Example 2
Source File: Util.java From tracker-control-android with GNU General Public License v3.0 | 5 votes |
public static String getNetworkGeneration(int networkType) { switch (networkType) { case TelephonyManager.NETWORK_TYPE_1xRTT: case TelephonyManager.NETWORK_TYPE_CDMA: case TelephonyManager.NETWORK_TYPE_EDGE: case TelephonyManager.NETWORK_TYPE_GPRS: case TelephonyManager.NETWORK_TYPE_IDEN: case TelephonyManager.NETWORK_TYPE_GSM: return "2G"; case TelephonyManager.NETWORK_TYPE_EHRPD: case TelephonyManager.NETWORK_TYPE_EVDO_0: case TelephonyManager.NETWORK_TYPE_EVDO_A: case TelephonyManager.NETWORK_TYPE_EVDO_B: case TelephonyManager.NETWORK_TYPE_HSDPA: case TelephonyManager.NETWORK_TYPE_HSPA: case TelephonyManager.NETWORK_TYPE_HSPAP: case TelephonyManager.NETWORK_TYPE_HSUPA: case TelephonyManager.NETWORK_TYPE_UMTS: case TelephonyManager.NETWORK_TYPE_TD_SCDMA: return "3G"; case TelephonyManager.NETWORK_TYPE_LTE: case TelephonyManager.NETWORK_TYPE_IWLAN: return "4G"; default: return "?G"; } }
Example 3
Source File: Util.java From Telegram with GNU General Public License v2.0 | 5 votes |
private static @C.NetworkType int getMobileNetworkType(NetworkInfo networkInfo) { switch (networkInfo.getSubtype()) { case TelephonyManager.NETWORK_TYPE_EDGE: case TelephonyManager.NETWORK_TYPE_GPRS: return C.NETWORK_TYPE_2G; case TelephonyManager.NETWORK_TYPE_1xRTT: case TelephonyManager.NETWORK_TYPE_CDMA: case TelephonyManager.NETWORK_TYPE_EVDO_0: case TelephonyManager.NETWORK_TYPE_EVDO_A: case TelephonyManager.NETWORK_TYPE_EVDO_B: case TelephonyManager.NETWORK_TYPE_HSDPA: case TelephonyManager.NETWORK_TYPE_HSPA: case TelephonyManager.NETWORK_TYPE_HSUPA: case TelephonyManager.NETWORK_TYPE_IDEN: case TelephonyManager.NETWORK_TYPE_UMTS: case TelephonyManager.NETWORK_TYPE_EHRPD: case TelephonyManager.NETWORK_TYPE_HSPAP: case TelephonyManager.NETWORK_TYPE_TD_SCDMA: return C.NETWORK_TYPE_3G; case TelephonyManager.NETWORK_TYPE_LTE: return C.NETWORK_TYPE_4G; case TelephonyManager.NETWORK_TYPE_IWLAN: return C.NETWORK_TYPE_WIFI; case TelephonyManager.NETWORK_TYPE_GSM: case TelephonyManager.NETWORK_TYPE_UNKNOWN: default: // Future mobile network types. return C.NETWORK_TYPE_CELLULAR_UNKNOWN; } }
Example 4
Source File: Util.java From Telegram-FOSS with GNU General Public License v2.0 | 5 votes |
private static @C.NetworkType int getMobileNetworkType(NetworkInfo networkInfo) { switch (networkInfo.getSubtype()) { case TelephonyManager.NETWORK_TYPE_EDGE: case TelephonyManager.NETWORK_TYPE_GPRS: return C.NETWORK_TYPE_2G; case TelephonyManager.NETWORK_TYPE_1xRTT: case TelephonyManager.NETWORK_TYPE_CDMA: case TelephonyManager.NETWORK_TYPE_EVDO_0: case TelephonyManager.NETWORK_TYPE_EVDO_A: case TelephonyManager.NETWORK_TYPE_EVDO_B: case TelephonyManager.NETWORK_TYPE_HSDPA: case TelephonyManager.NETWORK_TYPE_HSPA: case TelephonyManager.NETWORK_TYPE_HSUPA: case TelephonyManager.NETWORK_TYPE_IDEN: case TelephonyManager.NETWORK_TYPE_UMTS: case TelephonyManager.NETWORK_TYPE_EHRPD: case TelephonyManager.NETWORK_TYPE_HSPAP: case TelephonyManager.NETWORK_TYPE_TD_SCDMA: return C.NETWORK_TYPE_3G; case TelephonyManager.NETWORK_TYPE_LTE: return C.NETWORK_TYPE_4G; case TelephonyManager.NETWORK_TYPE_IWLAN: return C.NETWORK_TYPE_WIFI; case TelephonyManager.NETWORK_TYPE_GSM: case TelephonyManager.NETWORK_TYPE_UNKNOWN: default: // Future mobile network types. return C.NETWORK_TYPE_CELLULAR_UNKNOWN; } }
Example 5
Source File: NetUtils.java From NoHttp with Apache License 2.0 | 5 votes |
private static boolean isMobileSubType(NetType netType, NetworkInfo networkInfo) { switch (networkInfo.getType()) { case TelephonyManager.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: { return netType == Mobile2G; } case TelephonyManager.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: { return netType == Mobile3G; } case TelephonyManager.NETWORK_TYPE_IWLAN: case TelephonyManager.NETWORK_TYPE_LTE: { return netType == Mobile4G; } default: { String subtypeName = networkInfo.getSubtypeName(); if (subtypeName.equalsIgnoreCase("TD-SCDMA") || subtypeName.equalsIgnoreCase("WCDMA") || subtypeName.equalsIgnoreCase("CDMA2000")) { return netType == Mobile3G; } break; } } return false; }
Example 6
Source File: Util.java From NetGuard with GNU General Public License v3.0 | 5 votes |
public static String getNetworkGeneration(int networkType) { switch (networkType) { case TelephonyManager.NETWORK_TYPE_1xRTT: case TelephonyManager.NETWORK_TYPE_CDMA: case TelephonyManager.NETWORK_TYPE_EDGE: case TelephonyManager.NETWORK_TYPE_GPRS: case TelephonyManager.NETWORK_TYPE_IDEN: case TelephonyManager.NETWORK_TYPE_GSM: return "2G"; case TelephonyManager.NETWORK_TYPE_EHRPD: case TelephonyManager.NETWORK_TYPE_EVDO_0: case TelephonyManager.NETWORK_TYPE_EVDO_A: case TelephonyManager.NETWORK_TYPE_EVDO_B: case TelephonyManager.NETWORK_TYPE_HSDPA: case TelephonyManager.NETWORK_TYPE_HSPA: case TelephonyManager.NETWORK_TYPE_HSPAP: case TelephonyManager.NETWORK_TYPE_HSUPA: case TelephonyManager.NETWORK_TYPE_UMTS: case TelephonyManager.NETWORK_TYPE_TD_SCDMA: return "3G"; case TelephonyManager.NETWORK_TYPE_LTE: case TelephonyManager.NETWORK_TYPE_IWLAN: return "4G"; default: return "?G"; } }
Example 7
Source File: NetworkTypeUtils.java From TowerCollector with Mozilla Public License 2.0 | 5 votes |
public static NetworkGroup getNetworkGroup(int networkType) { switch (networkType) { case TelephonyManager.NETWORK_TYPE_GSM: case TelephonyManager.NETWORK_TYPE_GPRS: case TelephonyManager.NETWORK_TYPE_EDGE: return NetworkGroup.Gsm; case TelephonyManager.NETWORK_TYPE_UMTS: case TelephonyManager.NETWORK_TYPE_HSPA: case TelephonyManager.NETWORK_TYPE_HSDPA: case TelephonyManager.NETWORK_TYPE_HSUPA: case TelephonyManager.NETWORK_TYPE_HSPAP: return NetworkGroup.Wcdma; case TelephonyManager.NETWORK_TYPE_1xRTT: case TelephonyManager.NETWORK_TYPE_CDMA: case TelephonyManager.NETWORK_TYPE_EHRPD: case TelephonyManager.NETWORK_TYPE_EVDO_0: case TelephonyManager.NETWORK_TYPE_EVDO_A: case TelephonyManager.NETWORK_TYPE_EVDO_B: return NetworkGroup.Cdma; case TelephonyManager.NETWORK_TYPE_LTE: return NetworkGroup.Lte; case TelephonyManager.NETWORK_TYPE_TD_SCDMA: return NetworkGroup.Tdscdma; case TelephonyManager.NETWORK_TYPE_NR: return NetworkGroup.Nr; case TelephonyManager.NETWORK_TYPE_IDEN: case TelephonyManager.NETWORK_TYPE_UNKNOWN: case TelephonyManager.NETWORK_TYPE_IWLAN: default: return NetworkGroup.Unknown; } }
Example 8
Source File: Util.java From TelePlus-Android with GNU General Public License v2.0 | 5 votes |
private static @C.NetworkType int getMobileNetworkType(NetworkInfo networkInfo) { switch (networkInfo.getSubtype()) { case TelephonyManager.NETWORK_TYPE_EDGE: case TelephonyManager.NETWORK_TYPE_GPRS: return C.NETWORK_TYPE_2G; case TelephonyManager.NETWORK_TYPE_1xRTT: case TelephonyManager.NETWORK_TYPE_CDMA: case TelephonyManager.NETWORK_TYPE_EVDO_0: case TelephonyManager.NETWORK_TYPE_EVDO_A: case TelephonyManager.NETWORK_TYPE_EVDO_B: case TelephonyManager.NETWORK_TYPE_HSDPA: case TelephonyManager.NETWORK_TYPE_HSPA: case TelephonyManager.NETWORK_TYPE_HSUPA: case TelephonyManager.NETWORK_TYPE_IDEN: case TelephonyManager.NETWORK_TYPE_UMTS: case TelephonyManager.NETWORK_TYPE_EHRPD: case TelephonyManager.NETWORK_TYPE_HSPAP: case TelephonyManager.NETWORK_TYPE_TD_SCDMA: return C.NETWORK_TYPE_3G; case TelephonyManager.NETWORK_TYPE_LTE: return C.NETWORK_TYPE_4G; case TelephonyManager.NETWORK_TYPE_IWLAN: return C.NETWORK_TYPE_WIFI; case TelephonyManager.NETWORK_TYPE_GSM: case TelephonyManager.NETWORK_TYPE_UNKNOWN: default: // Future mobile network types. return C.NETWORK_TYPE_CELLULAR_UNKNOWN; } }
Example 9
Source File: NetworkChecker.java From Kalle with Apache License 2.0 | 5 votes |
private static boolean isMobileSubType(NetType netType, NetworkInfo networkInfo) { switch (networkInfo.getType()) { case TelephonyManager.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: { return netType == Mobile2G; } case TelephonyManager.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: { return netType == Mobile3G; } case TelephonyManager.NETWORK_TYPE_IWLAN: case TelephonyManager.NETWORK_TYPE_LTE: { return netType == Mobile4G; } default: { String subtypeName = networkInfo.getSubtypeName(); if (subtypeName.equalsIgnoreCase("TD-SCDMA") || subtypeName.equalsIgnoreCase("WCDMA") || subtypeName.equalsIgnoreCase("CDMA2000")) { return netType == Mobile3G; } break; } } return false; }
Example 10
Source File: Util.java From TelePlus-Android with GNU General Public License v2.0 | 5 votes |
private static @C.NetworkType int getMobileNetworkType(NetworkInfo networkInfo) { switch (networkInfo.getSubtype()) { case TelephonyManager.NETWORK_TYPE_EDGE: case TelephonyManager.NETWORK_TYPE_GPRS: return C.NETWORK_TYPE_2G; case TelephonyManager.NETWORK_TYPE_1xRTT: case TelephonyManager.NETWORK_TYPE_CDMA: case TelephonyManager.NETWORK_TYPE_EVDO_0: case TelephonyManager.NETWORK_TYPE_EVDO_A: case TelephonyManager.NETWORK_TYPE_EVDO_B: case TelephonyManager.NETWORK_TYPE_HSDPA: case TelephonyManager.NETWORK_TYPE_HSPA: case TelephonyManager.NETWORK_TYPE_HSUPA: case TelephonyManager.NETWORK_TYPE_IDEN: case TelephonyManager.NETWORK_TYPE_UMTS: case TelephonyManager.NETWORK_TYPE_EHRPD: case TelephonyManager.NETWORK_TYPE_HSPAP: case TelephonyManager.NETWORK_TYPE_TD_SCDMA: return C.NETWORK_TYPE_3G; case TelephonyManager.NETWORK_TYPE_LTE: return C.NETWORK_TYPE_4G; case TelephonyManager.NETWORK_TYPE_IWLAN: return C.NETWORK_TYPE_WIFI; case TelephonyManager.NETWORK_TYPE_GSM: case TelephonyManager.NETWORK_TYPE_UNKNOWN: default: // Future mobile network types. return C.NETWORK_TYPE_CELLULAR_UNKNOWN; } }
Example 11
Source File: Util.java From MediaSDK with Apache License 2.0 | 5 votes |
private static @C.NetworkType int getMobileNetworkType(NetworkInfo networkInfo) { switch (networkInfo.getSubtype()) { case TelephonyManager.NETWORK_TYPE_EDGE: case TelephonyManager.NETWORK_TYPE_GPRS: return C.NETWORK_TYPE_2G; case TelephonyManager.NETWORK_TYPE_1xRTT: case TelephonyManager.NETWORK_TYPE_CDMA: case TelephonyManager.NETWORK_TYPE_EVDO_0: case TelephonyManager.NETWORK_TYPE_EVDO_A: case TelephonyManager.NETWORK_TYPE_EVDO_B: case TelephonyManager.NETWORK_TYPE_HSDPA: case TelephonyManager.NETWORK_TYPE_HSPA: case TelephonyManager.NETWORK_TYPE_HSUPA: case TelephonyManager.NETWORK_TYPE_IDEN: case TelephonyManager.NETWORK_TYPE_UMTS: case TelephonyManager.NETWORK_TYPE_EHRPD: case TelephonyManager.NETWORK_TYPE_HSPAP: case TelephonyManager.NETWORK_TYPE_TD_SCDMA: return C.NETWORK_TYPE_3G; case TelephonyManager.NETWORK_TYPE_LTE: return C.NETWORK_TYPE_4G; case TelephonyManager.NETWORK_TYPE_IWLAN: return C.NETWORK_TYPE_WIFI; case TelephonyManager.NETWORK_TYPE_GSM: case TelephonyManager.NETWORK_TYPE_UNKNOWN: default: // Future mobile network types. return C.NETWORK_TYPE_CELLULAR_UNKNOWN; } }
Example 12
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 13
Source File: NeihanManager.java From CrazyDaily with Apache License 2.0 | 4 votes |
private String getNetworkType() { NetworkInfo info = ((ConnectivityManager) mNeihanPreference.getContext().getSystemService(Context.CONNECTIVITY_SERVICE)).getActiveNetworkInfo(); if (info != null && info.isAvailable()) { if (info.getType() == ConnectivityManager.TYPE_WIFI) { return "wifi"; } else if (info.getType() == ConnectivityManager.TYPE_MOBILE) { switch (info.getSubtype()) { case TelephonyManager.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: return "2g"; case TelephonyManager.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: return "3g"; case TelephonyManager.NETWORK_TYPE_IWLAN: case TelephonyManager.NETWORK_TYPE_LTE: return "4g"; default: String subtypeName = info.getSubtypeName(); if (subtypeName.equalsIgnoreCase("TD-SCDMA") || subtypeName.equalsIgnoreCase("WCDMA") || subtypeName.equalsIgnoreCase("CDMA2000")) { return "3g"; } else { return "wifi"; } } } else { return "wifi"; } } return "wifi"; }
Example 14
Source File: NetworkUtils.java From AndroidUtilCode with Apache License 2.0 | 4 votes |
/** * Return type of network. * <p>Must hold {@code <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />}</p> * * @return type of network * <ul> * <li>{@link NetworkUtils.NetworkType#NETWORK_ETHERNET} </li> * <li>{@link NetworkUtils.NetworkType#NETWORK_WIFI } </li> * <li>{@link NetworkUtils.NetworkType#NETWORK_4G } </li> * <li>{@link NetworkUtils.NetworkType#NETWORK_3G } </li> * <li>{@link NetworkUtils.NetworkType#NETWORK_2G } </li> * <li>{@link NetworkUtils.NetworkType#NETWORK_UNKNOWN } </li> * <li>{@link NetworkUtils.NetworkType#NETWORK_NO } </li> * </ul> */ @RequiresPermission(ACCESS_NETWORK_STATE) public static NetworkType getNetworkType() { if (isEthernet()) { return NetworkType.NETWORK_ETHERNET; } NetworkInfo info = getActiveNetworkInfo(); if (info != null && info.isAvailable()) { if (info.getType() == ConnectivityManager.TYPE_WIFI) { return NetworkType.NETWORK_WIFI; } else if (info.getType() == ConnectivityManager.TYPE_MOBILE) { switch (info.getSubtype()) { case TelephonyManager.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: return NetworkType.NETWORK_2G; case TelephonyManager.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: return NetworkType.NETWORK_3G; case TelephonyManager.NETWORK_TYPE_IWLAN: case TelephonyManager.NETWORK_TYPE_LTE: return NetworkType.NETWORK_4G; case TelephonyManager.NETWORK_TYPE_NR: return NetworkType.NETWORK_5G; default: String subtypeName = info.getSubtypeName(); if (subtypeName.equalsIgnoreCase("TD-SCDMA") || subtypeName.equalsIgnoreCase("WCDMA") || subtypeName.equalsIgnoreCase("CDMA2000")) { return NetworkType.NETWORK_3G; } else { return NetworkType.NETWORK_UNKNOWN; } } } else { return NetworkType.NETWORK_UNKNOWN; } } return NetworkType.NETWORK_NO; }
Example 15
Source File: chat_command_service.java From telegram-sms with BSD 3-Clause "New" or "Revised" License | 4 votes |
private String check_cellular_network_type(int type, boolean is_att) { String net_type = "Unknown"; switch (type) { case TelephonyManager.NETWORK_TYPE_NR: net_type = "5G"; if (is_att) { net_type = "5G+"; } break; case TelephonyManager.NETWORK_TYPE_LTE: net_type = "LTE"; if (is_att) { net_type = "5G E"; } break; case TelephonyManager.NETWORK_TYPE_HSPAP: if (is_att) { net_type = "4G"; break; } case TelephonyManager.NETWORK_TYPE_EVDO_0: case TelephonyManager.NETWORK_TYPE_EVDO_A: case TelephonyManager.NETWORK_TYPE_EVDO_B: case TelephonyManager.NETWORK_TYPE_EHRPD: case TelephonyManager.NETWORK_TYPE_HSDPA: case TelephonyManager.NETWORK_TYPE_HSUPA: case TelephonyManager.NETWORK_TYPE_HSPA: case TelephonyManager.NETWORK_TYPE_TD_SCDMA: case TelephonyManager.NETWORK_TYPE_UMTS: net_type = "3G"; break; 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: net_type = "2G"; break; } return net_type; }
Example 16
Source File: NetworkUtils.java From Android-utils with Apache License 2.0 | 4 votes |
@RequiresPermission(ACCESS_NETWORK_STATE) public static NetworkType getNetworkType() { NetworkType netType = NetworkType.NETWORK_NO; NetworkInfo info = getActiveNetworkInfo(); if (info != null && info.isAvailable()) { if (info.getType() == ConnectivityManager.TYPE_ETHERNET) { netType = NetworkType.NETWORK_ETHERNET; } else if (info.getType() == ConnectivityManager.TYPE_WIFI) { netType = NetworkType.NETWORK_WIFI; } else if (info.getType() == ConnectivityManager.TYPE_MOBILE) { switch (info.getSubtype()) { case TelephonyManager.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 = NetworkType.NETWORK_2G; break; case TelephonyManager.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 = NetworkType.NETWORK_3G; break; case TelephonyManager.NETWORK_TYPE_IWLAN: case TelephonyManager.NETWORK_TYPE_LTE: netType = NetworkType.NETWORK_4G; break; default: String subtypeName = info.getSubtypeName(); if (subtypeName.equalsIgnoreCase("TD-SCDMA") || subtypeName.equalsIgnoreCase("WCDMA") || subtypeName.equalsIgnoreCase("CDMA2000")) { netType = NetworkType.NETWORK_3G; } else { netType = NetworkType.NETWORK_UNKNOWN; } break; } } else { netType = NetworkType.NETWORK_UNKNOWN; } } return netType; }
Example 17
Source File: NetworkUtil.java From AndroidWallet with GNU General Public License v3.0 | 4 votes |
/** * 获取当前网络类型 * 需添加权限 {@code <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>} */ @RequiresPermission("android.permission.ACCESS_NETWORK_STATE") public static NetworkType getNetworkType(Context context) { NetworkType netType = NetworkType.NETWORK_NO; NetworkInfo info = getActiveNetworkInfo(context); if (info != null && info.isAvailable()) { if (info.getType() == ConnectivityManager.TYPE_WIFI) { netType = NetworkType.NETWORK_WIFI; } else if (info.getType() == ConnectivityManager.TYPE_MOBILE) { switch (info.getSubtype()) { case TelephonyManager.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 = NetworkType.NETWORK_3G; break; case TelephonyManager.NETWORK_TYPE_LTE: case TelephonyManager.NETWORK_TYPE_IWLAN: netType = NetworkType.NETWORK_4G; break; case TelephonyManager.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 = NetworkType.NETWORK_2G; break; default: String subtypeName = info.getSubtypeName(); if (subtypeName.equalsIgnoreCase("TD-SCDMA") || subtypeName.equalsIgnoreCase("WCDMA") || subtypeName.equalsIgnoreCase("CDMA2000")) { netType = NetworkType.NETWORK_3G; } else { netType = NetworkType.NETWORK_UNKNOWN; } break; } } else { netType = NetworkType.NETWORK_UNKNOWN; } } return netType; }