如何从特定的蓝牙配置文件获取连接的设备列表 [英] How to get the connected device list from a specific bluetooth profile

查看:183
本文介绍了如何从特定的蓝牙配置文件获取连接的设备列表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

无论如何,都可以从支持配置文件(HDD,Spp和音频)中获取已连接的设备列表.要求就像我的设备将支持HDD,SPP和音频,因此我必须过滤支持所有这些配置文件的设备.反正有过滤设备吗?

Is there anyway to get the connected devices list from support profiles (HDD,Spp and audio). The requirement is like my device will support HDD,SPP and Audio, so i have to filter the devices which supports all these profiles. Is there anyway to filter the devices?

推荐答案

可以,但是您的Android应用程序必须以SDK 11或更高版本为目标(

Yes that is possible but your Android application must target SDK 11 or later (Android 3.0.X).

问题的解决方案是,您必须查询Android设备已知的所有BluetoothDevices. 已知是指所有配对的已连接或未连接的设备以​​及未配对的已连接设备.

The solution to your question is that you have to query all BluetoothDevices known by your Android device. By known I mean all paired connected or unconnected devices and unpaired connected devices.

我们稍后将过滤掉未连接的设备,因为您只需要当前已连接的设备.

We will filter out unconnected devices later since you only want currently connected devices.

  • 首先,您需要检索BluetoothAdapter:

最终BluetoothAdapter btAdapter = BluetoothAdapter.getDefaultAdapter();

final BluetoothAdapter btAdapter = BluetoothAdapter.getDefaultAdapter();

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆