Android 获取蓝牙设备类型

本文介绍如何在Android中获取蓝牙设备的类型,区别于蓝牙Profile,设备类型包括手机、电脑、手柄等。通过BluetoothDevice的getBluetoothClass方法获取BluetoothClass,它定义了主要类型如计算机、音频设备等,以及子类型,帮助识别如游戏手柄、键盘等设备。
摘要由CSDN通过智能技术生成

之前我们分析了如何获取已连接的蓝牙设备地址

http://blog.csdn.net/jasonwang18/article/details/61214431

本篇我们分析如何获取对应蓝牙设备的类型,这个类型和profile不是同一个东西,而是具体蓝牙的设备类型,比如手机、电脑、手柄、蓝牙耳机等



我们看到手机搜索到的蓝牙设备类型有三种,手机、电脑和普通蓝牙

    /**
     * Get the Bluetooth device type of the remote device.
     *
     * <p>Requires {@link android.Manifest.permission#BLUETOOTH}
     *
     * @return the device type {@link #DEVICE_TYPE_CLASSIC}, {@link #DEVICE_TYPE_LE}
     *                         {@link #DEVICE_TYPE_DUAL}.
     *         {@link #DEVICE_TYPE_UNKNOWN} if it's not available
     */
    @RequiresPermission(Manifest.permission.BLUETOOTH)
    public int getType() {
        if (sService == null) {
            Log.e(TAG, "BT not enabled. Cannot get Remote Device type");
            return DEVICE_TYPE_UNKNOWN;
        }
        try {
            return sService.getRemoteType(this);
        } catch (RemoteExceptio
  • 4
    点赞
  • 19
    收藏
    觉得还不错? 一键收藏
  • 3
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值