Java Code Examples for android.net.ConnectivityManager#TYPE_MOBILE_MMS

The following examples show how to use android.net.ConnectivityManager#TYPE_MOBILE_MMS . 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: NetworkTypePreference.java    From satstat with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Regenerates the list of selectable networks.
 */
public void updateNetworks() {
	NetworkInfo[] allnetinfo = ((ConnectivityManager) mContext.getSystemService(Context.CONNECTIVITY_SERVICE)).getAllNetworkInfo();
	if (allnetinfo != null) {
		List<CharSequence> entries = new ArrayList<CharSequence>();
		List<CharSequence> values = new ArrayList<CharSequence>();
		
		for (NetworkInfo ni : allnetinfo) {
			if ((ni.getType() < ConnectivityManager.TYPE_MOBILE_MMS) || (ni.getType() > ConnectivityManager.TYPE_MOBILE_HIPRI)) {
				// filter out specific mobile data connections, we'll catch those with the Mobile setting
				entries.add(ni.getTypeName());
				//entries.add(ni.getTypeName() + " (" + Integer.toString(ni.getType()) + ")");
				values.add(Integer.toString(ni.getType()));
			}
		}
		
		setEntries(entries.toArray(new CharSequence[]{}));
		setEntryValues(values.toArray(new CharSequence[]{}));
	}
}
 
Example 2
Source File: NetworkInfoBroadcastReceiver.java    From android-sdk with MIT License 6 votes vote down vote up
private static String typeToString(int type) {
    switch (type) {
        case ConnectivityManager.TYPE_ETHERNET:
            return "TYPE_ETHERNET";
        case ConnectivityManager.TYPE_BLUETOOTH:
            return "TYPE_BLUETOOTH";
        case ConnectivityManager.TYPE_MOBILE:
            return "TYPE_MOBILE";
        case ConnectivityManager.TYPE_MOBILE_DUN:
            return "TYPE_MOBILE_DUN";
        case ConnectivityManager.TYPE_MOBILE_HIPRI:
            return "TYPE_MOBILE_HIPRI";
        case ConnectivityManager.TYPE_MOBILE_MMS:
            return "TYPE_MOBILE_MMS";
        case ConnectivityManager.TYPE_MOBILE_SUPL:
            return "TYPE_MOBILE_SUPL";
        case ConnectivityManager.TYPE_VPN:
            return "TYPE_VPN";
        case ConnectivityManager.TYPE_WIFI:
            return "TYPE_WIFI";
        case ConnectivityManager.TYPE_WIMAX:
            return "TYPE_WIMAX";
        default:
            return "unknown";
    }
}
 
Example 3
Source File: NetWorkUtils.java    From BigApp_Discuz_Android with Apache License 2.0 6 votes vote down vote up
public static String getNetworkTypeReabable(Context context) {
    final ConnectivityManager conMgr = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
    final NetworkInfo activeNetInfo = conMgr.getActiveNetworkInfo();
    if (activeNetInfo != null && activeNetInfo.isAvailable() && activeNetInfo.isConnected()) {
        switch (activeNetInfo.getType()) {
            case ConnectivityManager.TYPE_WIFI:
                return "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:
            case ConnectivityManager.TYPE_WIMAX:
                return "mobile";
            default:
                return "mobile";


        }
    } else
        return "none";
}
 
Example 4
Source File: NetworkUtil.java    From landlord_client with Apache License 2.0 5 votes vote down vote up
/**
 * 获取网络连接类型
 * <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 5
Source File: Utils.java    From flickr-uploader with GNU General Public License v2.0 5 votes vote down vote up
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 6
Source File: Network.java    From android-common with Apache License 2.0 5 votes vote down vote up
/**
 * 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 7
Source File: NetworkUtil.java    From NIM_Android_UIKit with MIT License 5 votes vote down vote up
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 8
Source File: NetworkUtil.java    From RxZhihuDaily with MIT License 5 votes vote down vote up
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 9
Source File: NetworkManagerFinal.java    From zone-sdk with MIT License 5 votes vote down vote up
/**
 * 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 10
Source File: NetWorkUtil.java    From AndroidBase with Apache License 2.0 5 votes vote down vote up
/**
 * 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 11
Source File: NetworkUtils.java    From SprintNBA with Apache License 2.0 5 votes vote down vote up
/**
 * 获取网络连接类型
 * <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 12
Source File: NetCheck.java    From HaiNaBaiChuan with Apache License 2.0 5 votes vote down vote up
/**
 * 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 13
Source File: Network.java    From MarkdownEditors with Apache License 2.0 5 votes vote down vote up
/**
 * 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 NetWorkType getNetworkType() {
    int type = getConnectedTypeINT();
    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().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: Network.java    From PicKing with Apache License 2.0 5 votes vote down vote up
/**
 * 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 15
Source File: NetworkUtils.java    From JianshuApp with GNU General Public License v3.0 4 votes vote down vote up
/**
 * 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 16
Source File: InformationCollector.java    From open-rmbt with Apache License 2.0 4 votes vote down vote up
/** 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 17
Source File: NetworkInfo.java    From raygun4android with MIT License 4 votes vote down vote up
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 GankGirl with GNU Lesser General Public License v2.1 2 votes vote down vote up
/**
 * 判断当前网络的类型是否是MobileMms
 *
 * @param context 上下文
 * @return 当前网络的类型是否是MobileMms。false:当前没有网络连接或者网络类型不是MobileMms
 */
public static boolean isMobileMmsByType(Context context) {
    return getCurrentNetworkType(context) ==
            ConnectivityManager.TYPE_MOBILE_MMS;
}
 
Example 19
Source File: NetWorkUtils.java    From Simpler with Apache License 2.0 2 votes vote down vote up
/**
 * 判断当前网络的类型是否是MobileMms
 *
 * @param context 上下文
 * @return 当前网络的类型是否是MobileMms。false:当前没有网络连接或者网络类型不是MobileMms
 */
public static boolean isMobileMmsByType(Context context) {
    return getCurrentNetworkType(context) ==
            ConnectivityManager.TYPE_MOBILE_MMS;
}
 
Example 20
Source File: AppNetworkMgr.java    From AndroidWallet with GNU General Public License v3.0 2 votes vote down vote up
/**
 * 判断当前网络的类型是否是MobileMms
 *
 * @param context 上下文
 * @return 当前网络的类型是否是MobileMms。false:当前没有网络连接或者网络类型不是MobileMms
 */
public static boolean isMobileMmsByType(Context context) {
    return getCurrentNetworkType(context) ==
            ConnectivityManager.TYPE_MOBILE_MMS;
}