当前位置: 首页>>代码示例>>Java>>正文


Java ConnectivityManager.TYPE_BLUETOOTH属性代码示例

本文整理汇总了Java中android.net.ConnectivityManager.TYPE_BLUETOOTH属性的典型用法代码示例。如果您正苦于以下问题:Java ConnectivityManager.TYPE_BLUETOOTH属性的具体用法?Java ConnectivityManager.TYPE_BLUETOOTH怎么用?Java ConnectivityManager.TYPE_BLUETOOTH使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在android.net.ConnectivityManager的用法示例。


在下文中一共展示了ConnectivityManager.TYPE_BLUETOOTH属性的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getConnectivityStatus

/**
 * Uses the provided context to determine the current connectivity status.
 *
 * @param context A context used to retrieve connection information from
 * @return A non-null value defined in {@link Status}
 */
public static Status getConnectivityStatus(Context context) {
    ConnectivityManager cm = (ConnectivityManager) context
            .getSystemService(Context.CONNECTIVITY_SERVICE);

    NetworkInfo activeNetwork = cm.getActiveNetworkInfo();
    switch (activeNetwork != null ? activeNetwork.getType() : CONST_NO_NETWORK) {
        case ConnectivityManager.TYPE_WIFI:
        case ConnectivityManager.TYPE_ETHERNET:
            return Status.WIFI;
        case ConnectivityManager.TYPE_MOBILE:
        case ConnectivityManager.TYPE_BLUETOOTH:
        case ConnectivityManager.TYPE_WIMAX:
            return Status.MOBILE;
        default:
            return Status.NONE;
    }
}
 
开发者ID:ccrama,项目名称:Slide-RSS,代码行数:23,代码来源:NetworkUtil.java

示例2: connectionTypeString

private String connectionTypeString(int connectionType) {
    switch (connectionType) {
        case ConnectivityManager.TYPE_WIFI:
            return "Wifi";
        case ConnectivityManager.TYPE_BLUETOOTH:
            return "Bluetooth";
        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";
        default:
            return "Unknown";
    }
}
 
开发者ID:wkmeijer,项目名称:CS4160-trustchain-android,代码行数:18,代码来源:PeerListAdapter.java

示例3: convertAndroidNetworkTypeToConnectionType

/** Returns the NCN network type corresponding to the connectivity manager network type */
protected int convertAndroidNetworkTypeToConnectionType(int connectivityManagerNetworkType) {
    if (connectivityManagerNetworkType == ConnectivityManager.TYPE_WIFI) {
        return ConnectionType.CONNECTION_WIFI;
    }
    // for mobile, we don't know if it is 2G, 3G, or 4G, default to worst case of 2G.
    if (connectivityManagerNetworkType == ConnectivityManager.TYPE_MOBILE) {
        return ConnectionType.CONNECTION_2G;
    }
    if (connectivityManagerNetworkType == ConnectivityManager.TYPE_BLUETOOTH) {
        return ConnectionType.CONNECTION_BLUETOOTH;
    }
    // Since NetworkConnectivityManager doesn't understand the other types, call them UNKNOWN.
    return ConnectionType.CONNECTION_UNKNOWN;
}
 
开发者ID:rkshuai,项目名称:chromium-for-android-56-debug-video,代码行数:15,代码来源:OfflinePageUtils.java

示例4: isBluetoothByType

/**
 * 判断当前网络的类型是否是蓝牙
 *
 * @param context 上下文
 * @return 当前网络的类型是否是蓝牙。false:当前没有网络连接或者网络类型不是蓝牙
 */
@TargetApi(Build.VERSION_CODES.HONEYCOMB_MR2)
public static boolean isBluetoothByType(Context context) {
    if (Build.VERSION.SDK_INT < Build.VERSION_CODES.HONEYCOMB_MR2) {
        return false;
    }
    else {
        return getCurrentNetworkType(context) ==
                ConnectivityManager.TYPE_BLUETOOTH;
    }
}
 
开发者ID:liying2008,项目名称:Simpler,代码行数:16,代码来源:NetWorkUtils.java

示例5: getNetworkTypeName

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);
	}
}
 
开发者ID:newDeepLearing,项目名称:decoy,代码行数:34,代码来源:NetworkUtil.java

示例6: getNetworkTypeName

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);
    }
}
 
开发者ID:angcyo,项目名称:RLibrary,代码行数:34,代码来源:NetworkUtil.java

示例7: getCurrentConnectionType

/**
 * Returns the connection type for the given NetworkState.
 */
public int getCurrentConnectionType(NetworkState networkState) {
    if (!networkState.isConnected()) {
        return ConnectionType.CONNECTION_NONE;
    }

    switch (networkState.getNetworkType()) {
        case ConnectivityManager.TYPE_ETHERNET:
            return ConnectionType.CONNECTION_ETHERNET;
        case ConnectivityManager.TYPE_WIFI:
            return ConnectionType.CONNECTION_WIFI;
        case ConnectivityManager.TYPE_WIMAX:
            return ConnectionType.CONNECTION_4G;
        case ConnectivityManager.TYPE_BLUETOOTH:
            return ConnectionType.CONNECTION_BLUETOOTH;
        case ConnectivityManager.TYPE_MOBILE:
            // Use information from TelephonyManager to classify the connection.
            switch (networkState.getNetworkSubType()) {
                case TelephonyManager.NETWORK_TYPE_GPRS:
                case TelephonyManager.NETWORK_TYPE_EDGE:
                case TelephonyManager.NETWORK_TYPE_CDMA:
                case TelephonyManager.NETWORK_TYPE_1xRTT:
                case TelephonyManager.NETWORK_TYPE_IDEN:
                    return ConnectionType.CONNECTION_2G;
                case TelephonyManager.NETWORK_TYPE_UMTS:
                case TelephonyManager.NETWORK_TYPE_EVDO_0:
                case TelephonyManager.NETWORK_TYPE_EVDO_A:
                case TelephonyManager.NETWORK_TYPE_HSDPA:
                case TelephonyManager.NETWORK_TYPE_HSUPA:
                case TelephonyManager.NETWORK_TYPE_HSPA:
                case TelephonyManager.NETWORK_TYPE_EVDO_B:
                case TelephonyManager.NETWORK_TYPE_EHRPD:
                case TelephonyManager.NETWORK_TYPE_HSPAP:
                    return ConnectionType.CONNECTION_3G;
                case TelephonyManager.NETWORK_TYPE_LTE:
                    return ConnectionType.CONNECTION_4G;
                default:
                    return ConnectionType.CONNECTION_UNKNOWN;
            }
        default:
            return ConnectionType.CONNECTION_UNKNOWN;
    }
}
 
开发者ID:lizhangqu,项目名称:chromium-net-for-android,代码行数:45,代码来源:NetworkChangeNotifierAutoDetect.java

示例8: getCurrentConnectionSubtype

/**
 * Returns the connection subtype for the given NetworkState.
 */
public int getCurrentConnectionSubtype(NetworkState networkState) {
    if (!networkState.isConnected()) {
        return ConnectionSubtype.SUBTYPE_NONE;
    }

    switch (networkState.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 (networkState.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;
    }
}
 
开发者ID:lizhangqu,项目名称:chromium-net-for-android,代码行数:54,代码来源:NetworkChangeNotifierAutoDetect.java

示例9: getNetwork

/** 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:
                //NetworkInfo.getSubtype() will return
                //one int representing an TelephonyManager.NETWORK_TYPE_XXX,
                //even if this is not documented
                //see https://dl.google.com/io/2009/pres/W_0300_CodingforLife-BatteryLifeThatIs.pdf
                //    https://stackoverflow.com/questions/25414830/networkinfo-subtype-values
                result = activeNetworkInfo.getSubtype();
                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;
}
 
开发者ID:rtr-nettest,项目名称:open-rmbt,代码行数:61,代码来源:InformationCollector.java

示例10: getConnectionType

public static ConnectionType getConnectionType(NetworkState networkState) {
  if (!networkState.isConnected()) {
    return ConnectionType.CONNECTION_NONE;
  }

  switch (networkState.getNetworkType()) {
    case ConnectivityManager.TYPE_ETHERNET:
      return ConnectionType.CONNECTION_ETHERNET;
    case ConnectivityManager.TYPE_WIFI:
      return ConnectionType.CONNECTION_WIFI;
    case ConnectivityManager.TYPE_WIMAX:
      return ConnectionType.CONNECTION_4G;
    case ConnectivityManager.TYPE_BLUETOOTH:
      return ConnectionType.CONNECTION_BLUETOOTH;
    case ConnectivityManager.TYPE_MOBILE:
      // Use information from TelephonyManager to classify the connection.
      switch (networkState.getNetworkSubType()) {
        case TelephonyManager.NETWORK_TYPE_GPRS:
        case TelephonyManager.NETWORK_TYPE_EDGE:
        case TelephonyManager.NETWORK_TYPE_CDMA:
        case TelephonyManager.NETWORK_TYPE_1xRTT:
        case TelephonyManager.NETWORK_TYPE_IDEN:
          return ConnectionType.CONNECTION_2G;
        case TelephonyManager.NETWORK_TYPE_UMTS:
        case TelephonyManager.NETWORK_TYPE_EVDO_0:
        case TelephonyManager.NETWORK_TYPE_EVDO_A:
        case TelephonyManager.NETWORK_TYPE_HSDPA:
        case TelephonyManager.NETWORK_TYPE_HSUPA:
        case TelephonyManager.NETWORK_TYPE_HSPA:
        case TelephonyManager.NETWORK_TYPE_EVDO_B:
        case TelephonyManager.NETWORK_TYPE_EHRPD:
        case TelephonyManager.NETWORK_TYPE_HSPAP:
          return ConnectionType.CONNECTION_3G;
        case TelephonyManager.NETWORK_TYPE_LTE:
          return ConnectionType.CONNECTION_4G;
        default:
          return ConnectionType.CONNECTION_UNKNOWN_CELLULAR;
      }
    default:
      return ConnectionType.CONNECTION_UNKNOWN;
  }
}
 
开发者ID:Piasy,项目名称:AppRTC-Android,代码行数:42,代码来源:NetworkMonitorAutoDetect.java

示例11: updateNetworkType

/**
 * Updates the network type based upon the type and subtype returned from
 * the connectivity manager. Subtype is only used for cellular signals.
 *
 * @param type
 * @param subType
 */
private void updateNetworkType(int type, int subType) {
    switch (type) {
        case ConnectivityManager.TYPE_WIFI:
        case ConnectivityManager.TYPE_ETHERNET:
        case ConnectivityManager.TYPE_BLUETOOTH:
            mIsCellularConnection = false;
            mIsAtLeast3G = false;
            mIsAtLeast4G = false;
            break;
        case ConnectivityManager.TYPE_WIMAX:
            mIsCellularConnection = true;
            mIsAtLeast3G = true;
            mIsAtLeast4G = true;
            break;
        case ConnectivityManager.TYPE_MOBILE:
            mIsCellularConnection = true;
            switch (subType) {
                case TelephonyManager.NETWORK_TYPE_1xRTT:
                case TelephonyManager.NETWORK_TYPE_CDMA:
                case TelephonyManager.NETWORK_TYPE_EDGE:
                case TelephonyManager.NETWORK_TYPE_GPRS:
                case TelephonyManager.NETWORK_TYPE_IDEN:
                    mIsAtLeast3G = false;
                    mIsAtLeast4G = false;
                    break;
                case TelephonyManager.NETWORK_TYPE_HSDPA:
                case TelephonyManager.NETWORK_TYPE_HSUPA:
                case TelephonyManager.NETWORK_TYPE_HSPA:
                case TelephonyManager.NETWORK_TYPE_EVDO_0:
                case TelephonyManager.NETWORK_TYPE_EVDO_A:
                case TelephonyManager.NETWORK_TYPE_UMTS:
                    mIsAtLeast3G = true;
                    mIsAtLeast4G = false;
                    break;
                case TelephonyManager.NETWORK_TYPE_LTE: // 4G
                case TelephonyManager.NETWORK_TYPE_EHRPD: // 3G ++ interop
                                                          // with 4G
                case TelephonyManager.NETWORK_TYPE_HSPAP: // 3G ++ but
                                                          // marketed as
                                                          // 4G
                    mIsAtLeast3G = true;
                    mIsAtLeast4G = true;
                    break;
                default:
                    mIsCellularConnection = false;
                    mIsAtLeast3G = false;
                    mIsAtLeast4G = false;
            }
    }
}
 
开发者ID:snoozinsquatch,项目名称:unity-obb-downloader,代码行数:57,代码来源:DownloaderService.java

示例12: updateNetworkType

/**
 * Updates the network type based upon the type and subtype returned from
 * the connectivity manager. Subtype is only used for cellular signals.
 * 
 * @param type
 * @param subType
 */
private void updateNetworkType(int type, int subType) {
    switch (type) {
        case ConnectivityManager.TYPE_WIFI:
        case ConnectivityManager.TYPE_ETHERNET:
        case ConnectivityManager.TYPE_BLUETOOTH:
            mIsCellularConnection = false;
            mIsAtLeast3G = false;
            mIsAtLeast4G = false;
            break;
        case ConnectivityManager.TYPE_WIMAX:
            mIsCellularConnection = true;
            mIsAtLeast3G = true;
            mIsAtLeast4G = true;
            break;
        case ConnectivityManager.TYPE_MOBILE:
            mIsCellularConnection = true;
            switch (subType) {
                case TelephonyManager.NETWORK_TYPE_1xRTT:
                case TelephonyManager.NETWORK_TYPE_CDMA:
                case TelephonyManager.NETWORK_TYPE_EDGE:
                case TelephonyManager.NETWORK_TYPE_GPRS:
                case TelephonyManager.NETWORK_TYPE_IDEN:
                    mIsAtLeast3G = false;
                    mIsAtLeast4G = false;
                    break;
                case TelephonyManager.NETWORK_TYPE_HSDPA:
                case TelephonyManager.NETWORK_TYPE_HSUPA:
                case TelephonyManager.NETWORK_TYPE_HSPA:
                case TelephonyManager.NETWORK_TYPE_EVDO_0:
                case TelephonyManager.NETWORK_TYPE_EVDO_A:
                case TelephonyManager.NETWORK_TYPE_UMTS:
                    mIsAtLeast3G = true;
                    mIsAtLeast4G = false;
                    break;
                case TelephonyManager.NETWORK_TYPE_LTE: // 4G
                case TelephonyManager.NETWORK_TYPE_EHRPD: // 3G ++ interop
                                                          // with 4G
                case TelephonyManager.NETWORK_TYPE_HSPAP: // 3G ++ but
                                                          // marketed as
                                                          // 4G
                    mIsAtLeast3G = true;
                    mIsAtLeast4G = true;
                    break;
                default:
                    mIsCellularConnection = false;
                    mIsAtLeast3G = false;
                    mIsAtLeast4G = false;
            }
    }
}
 
开发者ID:SlotNSlot,项目名称:SlotNSlot_Android,代码行数:57,代码来源:DownloaderService.java


注:本文中的android.net.ConnectivityManager.TYPE_BLUETOOTH属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。