Java Code Examples for android.net.ConnectivityManager#TYPE_MOBILE_DUN
The following examples show how to use
android.net.ConnectivityManager#TYPE_MOBILE_DUN .
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: MultiProfile.java From Aria2App with GNU General Public License v3.0 | 6 votes |
@NonNull public UserProfile getProfile(int networkType, WifiManager wifiManager) { UserProfile profile = null; switch (networkType) { case ConnectivityManager.TYPE_WIMAX: case ConnectivityManager.TYPE_WIFI: String ssid = wifiManager.getConnectionInfo().getSSID(); if (ssid == null || ssid.length() <= 2) break; profile = findForWifi(ssid.substring(1, ssid.length() - 1)); break; case ConnectivityManager.TYPE_MOBILE_DUN: case ConnectivityManager.TYPE_MOBILE: profile = findFor(ConnectivityCondition.Type.MOBILE); break; case ConnectivityManager.TYPE_ETHERNET: profile = findFor(ConnectivityCondition.Type.ETHERNET); break; case ConnectivityManager.TYPE_BLUETOOTH: profile = findFor(ConnectivityCondition.Type.BLUETOOTH); break; } if (profile == null) return getDefaultProfile(); else return profile; }
Example 2
Source File: NetworkObserver.java From Dashchan with Apache License 2.0 | 6 votes |
private void onActiveNetworkChange() { int networkState = NETWORK_UNDEFINED; NetworkInfo networkInfo = connectivityManager.getActiveNetworkInfo(); if (networkInfo != null && networkInfo.isConnected()) { int type = networkInfo.getType(); switch (type) { case ConnectivityManager.TYPE_WIFI: case ConnectivityManager.TYPE_WIMAX: { networkState = NETWORK_WIFI; break; } case ConnectivityManager.TYPE_MOBILE: case ConnectivityManager.TYPE_MOBILE_DUN: { networkState = NETWORK_MOBILE; break; } } } this.networkState = networkState; last3GChecked = 0L; }
Example 3
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 4
Source File: NetworkManagerFinal.java From zone-sdk with MIT License | 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 5
Source File: NetWorkUtil.java From AndroidBase 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 6
Source File: Utils.java From flickr-uploader with GNU General Public License v2.0 | 5 votes |
public static CAN_UPLOAD canUploadNow() { if (!FlickrApi.isAuthentified()) { return CAN_UPLOAD.no_flickr_login; } if (System.currentTimeMillis() < Utils.getLongProperty(STR.manuallyPaused)) { return CAN_UPLOAD.manually; } if (Utils.getBooleanProperty(PreferencesActivity.CHARGING_ONLY, false)) { if (!checkIfCharging()) { return CAN_UPLOAD.charging; } } ConnectivityManager manager = (ConnectivityManager) FlickrUploader.getAppContext().getSystemService(Context.CONNECTIVITY_SERVICE); NetworkInfo activeNetwork = manager.getActiveNetworkInfo(); if (activeNetwork == null || !activeNetwork.isConnected()) { return CAN_UPLOAD.network; } // if wifi is disabled and the user preference only allows wifi abort if (sp.getString(PreferencesActivity.UPLOAD_NETWORK, "").equals(STR.wifionly)) { switch (activeNetwork.getType()) { case ConnectivityManager.TYPE_MOBILE: case ConnectivityManager.TYPE_MOBILE_DUN: case ConnectivityManager.TYPE_MOBILE_HIPRI: case ConnectivityManager.TYPE_MOBILE_MMS: case ConnectivityManager.TYPE_MOBILE_SUPL: return CAN_UPLOAD.wifi; default: break; } } return CAN_UPLOAD.ok; }
Example 7
Source File: DeviceStatusUtil.java From under-the-hood with Apache License 2.0 | 5 votes |
/** * The current network (ie. internet) connectivity state. Needs correct permission to work. * * @param context * @return state */ //@RequiresPermission(Manifest.permission.ACCESS_NETWORK_STATE) public static ConnectionState getNetworkConnectivityState(@NonNull Context context) { if (ContextCompat.checkSelfPermission(context, Manifest.permission.ACCESS_NETWORK_STATE) == PackageManager.PERMISSION_GRANTED) { ConnectivityManager cm = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE); NetworkInfo activeNetwork = cm.getActiveNetworkInfo(); if (activeNetwork != null) { if (activeNetwork.isConnectedOrConnecting()) { if (activeNetwork.getType() == ConnectivityManager.TYPE_WIFI) { return ConnectionState.CONNECTED_WIFI; } if (activeNetwork.getType() == ConnectivityManager.TYPE_MOBILE || activeNetwork.getType() == ConnectivityManager.TYPE_MOBILE_DUN) { return ConnectionState.CONNECTED_MOBILE; } if (activeNetwork.getType() == ConnectivityManager.TYPE_ETHERNET) { return ConnectionState.CONNECTED_ETHERNET; } if (activeNetwork.getType() == ConnectivityManager.TYPE_BLUETOOTH) { return ConnectionState.CONNECTED_BT; } if (activeNetwork.getType() == ConnectivityManager.TYPE_VPN) { return ConnectionState.CONNECTED_BT; } return ConnectionState.CONNECTED_OTHER; } } return ConnectionState.DISCONNECTED; } return ConnectionState.PERMISSION_NEEDED; }
Example 8
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 9
Source File: NetworkObserver.java From Dashchan with Apache License 2.0 | 5 votes |
public boolean isMobile3GConnected() { switch (networkState) { case NETWORK_WIFI: { return true; } case NETWORK_MOBILE: { synchronized (this) { if (System.currentTimeMillis() - last3GChecked >= 2000) { boolean is3GAvailable = false; NetworkInfo networkInfo = connectivityManager.getActiveNetworkInfo(); if (networkInfo != null && networkInfo.isConnected()) { int type = networkInfo.getType(); if (type == ConnectivityManager.TYPE_MOBILE || type == ConnectivityManager.TYPE_MOBILE_DUN) { switch (networkInfo.getSubtype()) { 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_LTE: { is3GAvailable = true; break; } } } } last3GAvailable = is3GAvailable; last3GChecked = System.currentTimeMillis(); } return last3GAvailable; } } } return false; }
Example 10
Source File: Util.java From MediaSDK with Apache License 2.0 | 5 votes |
/** * Returns the {@link C.NetworkType} of the current network connection. * * @param context A context to access the connectivity manager. * @return The {@link C.NetworkType} of the current network connection. */ @C.NetworkType public static int getNetworkType(Context context) { if (context == null) { // Note: This is for backward compatibility only (context used to be @Nullable). return C.NETWORK_TYPE_UNKNOWN; } NetworkInfo networkInfo; ConnectivityManager connectivityManager = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE); if (connectivityManager == null) { return C.NETWORK_TYPE_UNKNOWN; } try { networkInfo = connectivityManager.getActiveNetworkInfo(); } catch (SecurityException e) { // Expected if permission was revoked. return C.NETWORK_TYPE_UNKNOWN; } if (networkInfo == null || !networkInfo.isConnected()) { return C.NETWORK_TYPE_OFFLINE; } switch (networkInfo.getType()) { case ConnectivityManager.TYPE_WIFI: return C.NETWORK_TYPE_WIFI; case ConnectivityManager.TYPE_WIMAX: return C.NETWORK_TYPE_4G; case ConnectivityManager.TYPE_MOBILE: case ConnectivityManager.TYPE_MOBILE_DUN: case ConnectivityManager.TYPE_MOBILE_HIPRI: return getMobileNetworkType(networkInfo); case ConnectivityManager.TYPE_ETHERNET: return C.NETWORK_TYPE_ETHERNET; default: // VPN, Bluetooth, Dummy. return C.NETWORK_TYPE_OTHER; } }
Example 11
Source File: Util.java From TelePlus-Android with GNU General Public License v2.0 | 5 votes |
/** * Returns the {@link C.NetworkType} of the current network connection. {@link * C#NETWORK_TYPE_UNKNOWN} will be returned if the {@code ACCESS_NETWORK_STATE} permission is not * granted or the network connection type couldn't be determined. * * @param context A context to access the connectivity manager. * @return The {@link C.NetworkType} of the current network connection, or {@link * C#NETWORK_TYPE_UNKNOWN} if the {@code ACCESS_NETWORK_STATE} permission is not granted or * {@code context} is null. */ public static @C.NetworkType int getNetworkType(@Nullable Context context) { if (context == null) { return C.NETWORK_TYPE_UNKNOWN; } NetworkInfo networkInfo; try { ConnectivityManager connectivityManager = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE); if (connectivityManager == null) { return C.NETWORK_TYPE_UNKNOWN; } networkInfo = connectivityManager.getActiveNetworkInfo(); } catch (SecurityException e) { // Permission ACCESS_NETWORK_STATE not granted. return C.NETWORK_TYPE_UNKNOWN; } if (networkInfo == null || !networkInfo.isConnected()) { return C.NETWORK_TYPE_OFFLINE; } switch (networkInfo.getType()) { case ConnectivityManager.TYPE_WIFI: return C.NETWORK_TYPE_WIFI; case ConnectivityManager.TYPE_WIMAX: return C.NETWORK_TYPE_4G; case ConnectivityManager.TYPE_MOBILE: case ConnectivityManager.TYPE_MOBILE_DUN: case ConnectivityManager.TYPE_MOBILE_HIPRI: return getMobileNetworkType(networkInfo); case ConnectivityManager.TYPE_ETHERNET: return C.NETWORK_TYPE_ETHERNET; default: // Ethernet, VPN, Bluetooth, Dummy. return C.NETWORK_TYPE_OTHER; } }
Example 12
Source File: Util.java From android-notification-log with MIT License | 5 votes |
public static String getConnectivityType(Context context) { try { ConnectivityManager cm = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE); if(cm != null) { NetworkInfo networkInfo = cm.getActiveNetworkInfo(); if(networkInfo != null) { int type = networkInfo.getType(); switch (type) { case ConnectivityManager.TYPE_BLUETOOTH: return "bluetooth"; case ConnectivityManager.TYPE_DUMMY: return "dummy"; case ConnectivityManager.TYPE_ETHERNET: return "ethernet"; case ConnectivityManager.TYPE_MOBILE: return "mobile"; case ConnectivityManager.TYPE_MOBILE_DUN: return "mobile dun"; case ConnectivityManager.TYPE_VPN: return "vpn"; case ConnectivityManager.TYPE_WIFI: return "wifi"; case ConnectivityManager.TYPE_WIMAX: return "wimax"; default: return ""+type; } } else { return "none"; } } } catch (Exception e) { if(Const.DEBUG) e.printStackTrace(); } return "undefined"; }
Example 13
Source File: NetworkUtil.java From landlord_client 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 14
Source File: NetworkUtil.java From RxZhihuDaily with MIT License | 5 votes |
private static String getNetworkTypeName(int type) { switch (type) { case ConnectivityManager.TYPE_MOBILE: return "MOBILE"; case ConnectivityManager.TYPE_WIFI: return "WIFI"; case ConnectivityManager.TYPE_MOBILE_MMS: return "MOBILE_MMS"; case ConnectivityManager.TYPE_MOBILE_SUPL: return "MOBILE_SUPL"; case ConnectivityManager.TYPE_MOBILE_DUN: return "MOBILE_DUN"; case ConnectivityManager.TYPE_MOBILE_HIPRI: return "MOBILE_HIPRI"; case ConnectivityManager.TYPE_WIMAX: return "WIMAX"; case ConnectivityManager.TYPE_BLUETOOTH: return "BLUETOOTH"; case ConnectivityManager.TYPE_DUMMY: return "DUMMY"; case ConnectivityManager.TYPE_ETHERNET: return "ETHERNET"; case 10: // ConnectivityManager.TYPE_MOBILE_FOTA: return "MOBILE_FOTA"; case 11: // ConnectivityManager.TYPE_MOBILE_IMS: return "MOBILE_IMS"; case 12: // ConnectivityManager.TYPE_MOBILE_CBS: return "MOBILE_CBS"; case 13: // ConnectivityManager.TYPE_WIFI_P2P: return "WIFI_P2P"; default: return Integer.toString(type); } }
Example 15
Source File: InformationCollector.java From open-rmbt with Apache License 2.0 | 4 votes |
/** Returns the network that the phone is on (e.g. Wifi, Edge, GPRS, etc). */ public int getNetwork() { int result = TelephonyManager.NETWORK_TYPE_UNKNOWN; if (connManager != null) { final NetworkInfo activeNetworkInfo = connManager.getActiveNetworkInfo(); if (activeNetworkInfo != null) { final int type = activeNetworkInfo.getType(); switch (type) { case ConnectivityManager.TYPE_WIFI: result = NETWORK_WIFI; break; case ConnectivityManager.TYPE_BLUETOOTH: result = NETWORK_BLUETOOTH; break; case ConnectivityManager.TYPE_ETHERNET: result = NETWORK_ETHERNET; break; case ConnectivityManager.TYPE_MOBILE: case ConnectivityManager.TYPE_MOBILE_DUN: case ConnectivityManager.TYPE_MOBILE_HIPRI: case ConnectivityManager.TYPE_MOBILE_MMS: case ConnectivityManager.TYPE_MOBILE_SUPL: result = telManager.getNetworkType(); break; } } } /* detect change from wifi to mobile or reverse */ final int lastNetworkType = this.lastNetworkType.get(); if (result != TelephonyManager.NETWORK_TYPE_UNKNOWN && lastNetworkType != TelephonyManager.NETWORK_TYPE_UNKNOWN) { if ( (result == NETWORK_WIFI && lastNetworkType != NETWORK_WIFI) || (result != NETWORK_WIFI && lastNetworkType == NETWORK_WIFI) ) illegalNetworkTypeChangeDetcted.set(true); } if (result != lastNetworkType) { this.lastNetworkType.set(result); if (telListener != null) telListener.onSignalStrengthsChanged(null); } return result; }
Example 16
Source File: NetInfoModule.java From react-native-GPay with MIT License | 4 votes |
private void updateAndSendConnectionType() { String connectionType = CONNECTION_TYPE_UNKNOWN; String effectiveConnectionType = EFFECTIVE_CONNECTION_TYPE_UNKNOWN; try { NetworkInfo networkInfo = mConnectivityManager.getActiveNetworkInfo(); if (networkInfo == null || !networkInfo.isConnected()) { connectionType = CONNECTION_TYPE_NONE; } else { int networkType = networkInfo.getType(); switch (networkType) { case ConnectivityManager.TYPE_BLUETOOTH: connectionType = CONNECTION_TYPE_BLUETOOTH; break; case ConnectivityManager.TYPE_ETHERNET: connectionType = CONNECTION_TYPE_ETHERNET; break; case ConnectivityManager.TYPE_MOBILE: case ConnectivityManager.TYPE_MOBILE_DUN: connectionType = CONNECTION_TYPE_CELLULAR; effectiveConnectionType = getEffectiveConnectionType(networkInfo); break; case ConnectivityManager.TYPE_WIFI: connectionType = CONNECTION_TYPE_WIFI; break; case ConnectivityManager.TYPE_WIMAX: connectionType = CONNECTION_TYPE_WIMAX; break; default: connectionType = CONNECTION_TYPE_UNKNOWN; break; } } } catch (SecurityException e) { mNoNetworkPermission = true; connectionType = CONNECTION_TYPE_UNKNOWN; } String currentConnectivity = getCurrentConnectionType(); // It is possible to get multiple broadcasts for the same connectivity change, so we only // update and send an event when the connectivity has indeed changed. if (!connectionType.equalsIgnoreCase(mConnectionType) || !effectiveConnectionType.equalsIgnoreCase(mEffectiveConnectionType) || !currentConnectivity.equalsIgnoreCase(mConnectivityDeprecated)) { mConnectionType = connectionType; mEffectiveConnectionType = effectiveConnectionType; mConnectivityDeprecated = currentConnectivity; sendConnectivityChangedEvent(); } }
Example 17
Source File: NetworkInfo.java From raygun4android with MIT License | 4 votes |
private String readNetworkConnectivityState(Context context) { String result = "Not connected"; ConnectivityManager cm = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE); android.net.NetworkInfo info = cm.getActiveNetworkInfo(); if (info != null) { if (info.isConnected()) { result = "Connected - "; int type = info.getType(); switch (type) { case ConnectivityManager.TYPE_WIFI: result += "WiFi"; break; case ConnectivityManager.TYPE_WIMAX: result += "WiMax"; break; case ConnectivityManager.TYPE_MOBILE: case ConnectivityManager.TYPE_MOBILE_DUN: case ConnectivityManager.TYPE_MOBILE_HIPRI: case ConnectivityManager.TYPE_MOBILE_MMS: case ConnectivityManager.TYPE_MOBILE_SUPL: result += "Mobile - "; int subtype = info.getSubtype(); switch (subtype) { case TelephonyManager.NETWORK_TYPE_1xRTT: result += "1xRTT"; break; case TelephonyManager.NETWORK_TYPE_CDMA: result += "CDMA"; break; case TelephonyManager.NETWORK_TYPE_EDGE: result += "EDGE"; break; case TelephonyManager.NETWORK_TYPE_EVDO_0: result += "EVDO_0"; break; case TelephonyManager.NETWORK_TYPE_EVDO_A: result += "EVDO_A"; break; case TelephonyManager.NETWORK_TYPE_GPRS: result += "GPRS"; break; case TelephonyManager.NETWORK_TYPE_HSDPA: result += "HSDPA"; break; case TelephonyManager.NETWORK_TYPE_HSPA: result += "HSPA"; break; case TelephonyManager.NETWORK_TYPE_HSUPA: result += "HSUPA"; break; case TelephonyManager.NETWORK_TYPE_UMTS: result += "UMTS"; break; case TelephonyManager.NETWORK_TYPE_IDEN: // API level 8 result += "IDEN"; break; case TelephonyManager.NETWORK_TYPE_UNKNOWN: default: result += "subtype unknown/EVDO_B/EHRPD/LTE/HSPAP or similar"; } break; default: result += "unknown type"; } } } return result; }
Example 18
Source File: NetworkUtils.java From JianshuApp with GNU General Public License v3.0 | 4 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 = AppUtils.getContext(); int type = -1; NetworkInfo networkInfo = ((ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE)).getActiveNetworkInfo(); if (networkInfo != null) { type = networkInfo.getType(); } 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 = ((TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE)).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.MOBILE_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 NetworkType.MOBILE_3G; case TelephonyManager.NETWORK_TYPE_LTE: return NetworkType.MOBILE_4G; default: return NetworkType.MOBILE_UNKNOWN; } default: return NetworkType.UNKNOWN; } }
Example 19
Source File: NetWorkUtils.java From Simpler with Apache License 2.0 | 2 votes |
/** * 判断当前网络的类型是否是MobileDun * * @param context 上下文 * @return 当前网络的类型是否是MobileDun。false:当前没有网络连接或者网络类型不是MobileDun */ public static boolean isMobileDunByType(Context context) { return getCurrentNetworkType(context) == ConnectivityManager.TYPE_MOBILE_DUN; }
Example 20
Source File: AppNetworkMgr.java From AndroidWallet with GNU General Public License v3.0 | 2 votes |
/** * 判断当前网络的类型是否是MobileDun * * @param context 上下文 * @return 当前网络的类型是否是MobileDun。false:当前没有网络连接或者网络类型不是MobileDun */ public static boolean isMobileDunByType(Context context) { return getCurrentNetworkType(context) == ConnectivityManager.TYPE_MOBILE_DUN; }