Java Code Examples for android.telephony.TelephonyManager#NETWORK_TYPE_EVDO_0
The following examples show how to use
android.telephony.TelephonyManager#NETWORK_TYPE_EVDO_0 .
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: CellularDrawer.java From meter with Apache License 2.0 | 6 votes |
protected String getNetworkType(){ switch (tManager.getNetworkType()) { 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 "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 "3G"; case TelephonyManager.NETWORK_TYPE_LTE: return "4G"; default: return "Unknown"; } }
Example 2
Source File: UEDevice.java From Auie with GNU General Public License v2.0 | 6 votes |
/** * 获取网络类型 */ public static String getNetworkType(Context context){ NetworkInfo info = ((ConnectivityManager)context.getSystemService(Context.CONNECTIVITY_SERVICE)).getActiveNetworkInfo(); if (info == null) { return "无网络"; } if (info.getType() == ConnectivityManager.TYPE_WIFI) { return "WIFI"; } switch (info.getSubtype()) { case TelephonyManager.NETWORK_TYPE_UMTS: case TelephonyManager.NETWORK_TYPE_HSDPA: case TelephonyManager.NETWORK_TYPE_EVDO_0: case TelephonyManager.NETWORK_TYPE_EVDO_A: case TelephonyManager.NETWORK_TYPE_EVDO_B: return "3G"; case TelephonyManager.NETWORK_TYPE_GPRS: case TelephonyManager.NETWORK_TYPE_EDGE: case TelephonyManager.NETWORK_TYPE_CDMA: return "2G"; case TelephonyManager.NETWORK_TYPE_LTE: return "4G"; default: return ""; } }
Example 3
Source File: NetworkUtils.java From SprintNBA with Apache License 2.0 | 5 votes |
/** * 获取网络连接类型 * <p/> * 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 4
Source File: ImageLoaderUtil.java From LRecyclerView with Apache License 2.0 | 5 votes |
private static boolean isFastMobileNetwork(Context context) { TelephonyManager telephonyManager = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE); switch (telephonyManager.getNetworkType()) { 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: return false; default: return false; } }
Example 5
Source File: VoIPBaseService.java From TelePlus-Android with GNU General Public License v2.0 | 4 votes |
protected void updateNetworkType() { ConnectivityManager cm = (ConnectivityManager) getSystemService(CONNECTIVITY_SERVICE); NetworkInfo info = cm.getActiveNetworkInfo(); lastNetInfo = info; 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); } }
Example 6
Source File: ConnectivityWire.java From tinybus with Apache License 2.0 | 4 votes |
private void calculateConnectionType() { if (mConnected) { switch (mNetworkInfo.getType()) { case ConnectivityManager.TYPE_WIFI: case ConnectivityManager.TYPE_WIMAX: case ConnectivityManager.TYPE_ETHERNET: mConnectionType = CONNECTION_TYPE_FAST; break; case ConnectivityManager.TYPE_MOBILE: switch (mNetworkInfo.getSubtype()) { case TelephonyManager.NETWORK_TYPE_LTE: case TelephonyManager.NETWORK_TYPE_HSPAP: case TelephonyManager.NETWORK_TYPE_HSPA: case TelephonyManager.NETWORK_TYPE_EHRPD: mConnectionType = CONNECTION_TYPE_4G; break; case TelephonyManager.NETWORK_TYPE_UMTS: case TelephonyManager.NETWORK_TYPE_CDMA: case TelephonyManager.NETWORK_TYPE_HSDPA: case TelephonyManager.NETWORK_TYPE_HSUPA: case TelephonyManager.NETWORK_TYPE_EVDO_0: case TelephonyManager.NETWORK_TYPE_EVDO_A: case TelephonyManager.NETWORK_TYPE_EVDO_B: mConnectionType = CONNECTION_TYPE_3G; break; case TelephonyManager.NETWORK_TYPE_GPRS: case TelephonyManager.NETWORK_TYPE_EDGE: mConnectionType = CONNECTION_TYPE_2G; break; default: mConnectionType = CONNECTION_TYPE_UNKNOWN; } break; default: mConnectionType = CONNECTION_TYPE_UNKNOWN; } } else { mConnectionType = CONNECTION_TYPE_UNKNOWN; } }
Example 7
Source File: NetworkUtils.java From Android-UtilCode with Apache License 2.0 | 4 votes |
/** * 获取当前网络类型 * <p>需添加权限 {@code <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>}</p> * * @return 网络类型 * <ul> * <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> */ public static NetworkType getNetworkType() { NetworkType netType = NetworkType.NETWORK_NO; NetworkInfo info = getActiveNetworkInfo(); 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 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 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 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 8
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 9
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 10
Source File: NetworkUtils.java From fangzhuishushenqi 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 11
Source File: Util.java From kcanotify with GNU General Public License v3.0 | 4 votes |
public static String getNetworkTypeName(int networkType) { switch (networkType) { // 2G case TelephonyManager.NETWORK_TYPE_1xRTT: return "1xRTT"; case TelephonyManager.NETWORK_TYPE_CDMA: return "CDMA"; case TelephonyManager.NETWORK_TYPE_EDGE: return "EDGE"; case TelephonyManager.NETWORK_TYPE_GPRS: return "GPRS"; case TelephonyManager.NETWORK_TYPE_IDEN: return "IDEN"; // 3G case TelephonyManager.NETWORK_TYPE_EHRPD: return "EHRPD"; case TelephonyManager.NETWORK_TYPE_EVDO_0: return "EVDO_0"; case TelephonyManager.NETWORK_TYPE_EVDO_A: return "EVDO_A"; case TelephonyManager.NETWORK_TYPE_EVDO_B: return "EVDO_B"; case TelephonyManager.NETWORK_TYPE_HSDPA: return "HSDPA"; case TelephonyManager.NETWORK_TYPE_HSPA: return "HSPA"; case TelephonyManager.NETWORK_TYPE_HSPAP: return "HSPAP"; case TelephonyManager.NETWORK_TYPE_HSUPA: return "HSUPA"; case TelephonyManager.NETWORK_TYPE_UMTS: return "UMTS"; case NETWORK_TYPE_TD_SCDMA: return "TD_SCDMA"; // 4G case TelephonyManager.NETWORK_TYPE_LTE: return "LTE"; case NETWORK_TYPE_IWLAN: return "IWLAN"; default: return Integer.toString(networkType); } }
Example 12
Source File: DataUtil.java From MobileInfo with Apache License 2.0 | 4 votes |
/** * 拿到具体的网络类型 * * @param context * @return */ public static String networkTypeALL(Context context) { ConnectivityManager manager = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE); if (manager != null) { NetworkInfo networkInfo = manager.getNetworkInfo(ConnectivityManager.TYPE_WIFI); if (networkInfo != null && networkInfo.isConnectedOrConnecting()) { return "WIFI"; } } TelephonyManager telephonyManager = (TelephonyManager) context.getSystemService(Context .TELEPHONY_SERVICE); if (telephonyManager == null) { return "unknown"; } int networkType = telephonyManager.getNetworkType(); 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 "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 "3G"; case TelephonyManager.NETWORK_TYPE_LTE: return "4G"; default: return BaseData.UNKNOWN_PARAM; } }
Example 13
Source File: KCApiPlatform.java From kerkee_android with GNU General Public License v3.0 | 4 votes |
public static boolean isFastMobileNetwork(Context context) { TelephonyManager telephonyManager = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE); switch (telephonyManager.getNetworkType()) { 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: return false; default: return false; } }
Example 14
Source File: VoIPBaseService.java From Telegram-FOSS with GNU General Public License v2.0 | 4 votes |
protected int getNetworkType() { final NetworkInfo info = lastNetInfo = getActiveNetworkInfo(); int type = TgVoip.NET_TYPE_UNKNOWN; if (info != null) { switch (info.getType()) { case ConnectivityManager.TYPE_MOBILE: switch (info.getSubtype()) { case TelephonyManager.NETWORK_TYPE_GPRS: type = TgVoip.NET_TYPE_GPRS; break; case TelephonyManager.NETWORK_TYPE_EDGE: case TelephonyManager.NETWORK_TYPE_1xRTT: type = TgVoip.NET_TYPE_EDGE; break; case TelephonyManager.NETWORK_TYPE_UMTS: case TelephonyManager.NETWORK_TYPE_EVDO_0: type = TgVoip.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 = TgVoip.NET_TYPE_HSPA; break; case TelephonyManager.NETWORK_TYPE_LTE: type = TgVoip.NET_TYPE_LTE; break; default: type = TgVoip.NET_TYPE_OTHER_MOBILE; break; } break; case ConnectivityManager.TYPE_WIFI: type = TgVoip.NET_TYPE_WIFI; break; case ConnectivityManager.TYPE_ETHERNET: type = TgVoip.NET_TYPE_ETHERNET; break; } } return type; }
Example 15
Source File: Connectivity.java From intra42 with Apache License 2.0 | 4 votes |
/** * Check if the connection is fast * * @param type Type: Connected Interface (Wifi, Mobile) * @param subType SubType: TYpe of network. * @return Check if the connection is fast */ 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 16
Source File: OSUtilities.java From Yahala-Messenger 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_GPRS: return false; // ~ 100 kbps case TelephonyManager.NETWORK_TYPE_EVDO_0: return false; // ~25 kbps case TelephonyManager.NETWORK_TYPE_LTE: 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 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 true; // ~ 10+ Mbps case TelephonyManager.NETWORK_TYPE_UNKNOWN: default: return false; } } else { return false; } }
Example 17
Source File: PlayerUtils.java From DKVideoPlayer with Apache License 2.0 | 4 votes |
/** * 判断当前网络类型 */ public static int getNetworkType(Context context) { //改为context.getApplicationContext(),防止在Android 6.0上发生内存泄漏 ConnectivityManager connectMgr = (ConnectivityManager) context.getApplicationContext() .getSystemService(Context.CONNECTIVITY_SERVICE); if (connectMgr == null) { return NO_NETWORK; } NetworkInfo networkInfo = connectMgr.getActiveNetworkInfo(); if (networkInfo == null) { // 没有任何网络 return NO_NETWORK; } if (!networkInfo.isConnected()) { // 网络断开或关闭 return NETWORK_CLOSED; } if (networkInfo.getType() == ConnectivityManager.TYPE_ETHERNET) { // 以太网网络 return NETWORK_ETHERNET; } else if (networkInfo.getType() == ConnectivityManager.TYPE_WIFI) { // wifi网络,当激活时,默认情况下,所有的数据流量将使用此连接 return NETWORK_WIFI; } else if (networkInfo.getType() == ConnectivityManager.TYPE_MOBILE) { // 移动数据连接,不能与连接共存,如果wifi打开,则自动关闭 switch (networkInfo.getSubtype()) { // 2G 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: // 3G 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: // 4G case TelephonyManager.NETWORK_TYPE_LTE: // 5G case TelephonyManager.NETWORK_TYPE_NR: return NETWORK_MOBILE; } } // 未知网络 return NETWORK_UNKNOWN; }
Example 18
Source File: NetworkUtils.java From Trojan with Apache License 2.0 | 4 votes |
public static int getNetworkType(Context context) { if (null == context) { return NETWORK_NONE; } ConnectivityManager connectivityManager = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE); if (null == connectivityManager) { return NETWORK_NONE; } final NetworkInfo activeNetInfo = connectivityManager.getActiveNetworkInfo(); if (null == activeNetInfo || !activeNetInfo.isAvailable()) { return NETWORK_NONE; } else if (activeNetInfo.getType() == ConnectivityManager.TYPE_WIFI) { return NETWORK_WIFI; } else if (activeNetInfo.getType() == ConnectivityManager.TYPE_MOBILE) { final NetworkInfo.State state = activeNetInfo.getState(); final String subTypeName = activeNetInfo.getSubtypeName(); if (null != state) { switch (activeNetInfo.getSubtype()) { 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 NETWORK_2G; 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 NETWORK_3G; case TelephonyManager.NETWORK_TYPE_LTE: return NETWORK_4G; default: if (subTypeName.equalsIgnoreCase("TD-SCDMA") || subTypeName.equalsIgnoreCase("WCDMA") || subTypeName.equalsIgnoreCase("CDMA2000")) { return NETWORK_3G; } else { return NETWORK_UNKNOWN_MOBILE; } } } } return NETWORK_NONE; }
Example 19
Source File: NetworkStateUtil.java From star-zone-android with Apache License 2.0 | 4 votes |
/** * 获取当前的网络状态 :没有网络-0:WIFI网络1:4G网络-4:3G网络-3:2G网络-2 * 自定义 * * @param context * @return */ public static int getAPNType(Context context) { //结果返回值 int netType = 0; //获取手机所有连接管理对象 ConnectivityManager manager = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE); //获取NetworkInfo对象 NetworkInfo networkInfo = manager.getActiveNetworkInfo(); //NetworkInfo对象为空 则代表没有网络 if (networkInfo == null) { return netType; } //否则 NetworkInfo对象不为空 则获取该networkInfo的类型 int nType = networkInfo.getType(); if (nType == ConnectivityManager.TYPE_WIFI) { //WIFI netType = 1; } else if (nType == ConnectivityManager.TYPE_MOBILE) { int nSubType = networkInfo.getSubtype(); TelephonyManager telephonyManager = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE); //3G 联通的3G为UMTS或HSDPA 电信的3G为EVDO if (nSubType == TelephonyManager.NETWORK_TYPE_LTE && !telephonyManager.isNetworkRoaming()) { netType = 4; } else if (nSubType == TelephonyManager.NETWORK_TYPE_UMTS || nSubType == TelephonyManager.NETWORK_TYPE_HSDPA || nSubType == TelephonyManager.NETWORK_TYPE_EVDO_0 && !telephonyManager.isNetworkRoaming()) { netType = 3; //2G 移动和联通的2G为GPRS或EGDE,电信的2G为CDMA } else if (nSubType == TelephonyManager.NETWORK_TYPE_GPRS || nSubType == TelephonyManager.NETWORK_TYPE_EDGE || nSubType == TelephonyManager.NETWORK_TYPE_CDMA && !telephonyManager.isNetworkRoaming()) { netType = 2; } else { netType = 2; } } return netType; }
Example 20
Source File: DeviceUtils.java From AndroidWear-OpenWear with MIT License | 4 votes |
public static NetworkType getNetworkType(Context context) { NetworkType type = NetworkType.NETWORK_UNKNOWN; ConnectivityManager mConnMgr = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE); NetworkInfo mWifi = mConnMgr.getNetworkInfo(ConnectivityManager.TYPE_WIFI); if (mWifi != null && mWifi.isAvailable() && mWifi.isConnectedOrConnecting()) { type = NetworkType.NETWORK_WIFI; } else { NetworkInfo mMobile = mConnMgr.getNetworkInfo(ConnectivityManager.TYPE_MOBILE); if (mMobile != null && mMobile.isAvailable() && mMobile.isConnectedOrConnecting()) { int subType = mMobile.getSubtype(); 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: type = NetworkType.NETWORK_2_G; 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: type = NetworkType.NETWORK_3_G; break; case TelephonyManager.NETWORK_TYPE_LTE: type = NetworkType.NETWORK_4_G; break; } } else { type = NetworkType.NO_NETWORK; } } return type; }