android 蓝牙配置文件,在Android中,如何获取连接的蓝牙设备的配置文件?

在Android中,可以通过BroadcastReceiver构建连接的蓝牙设备列表。但要获取设备支持的具体配置文件,如A2DP,需要使用BluetoothProfile的getDevicesMatchingConnectionStates方法结合自定义的BluetoothProfile.ServiceListener。该方法能列出处于特定连接状态且支持特定配置文件的设备。
摘要由CSDN通过智能技术生成

在这里得到了很多答案,我可以在BroadcastReceiver的帮助下构建连接的蓝牙设备列表.现在我的问题是如何知道哪个设备支持哪个配置文件.我希望能够根据配置文件选择设备,例如,获取当前连接的设备及其配置文件的列表,然后选择其中一个.如果我有BluetoothDevice的实例,我不知道如何获得这样的信息.

非常感谢提前.

解决方法:

我遇到了同样的问题.您似乎无法从BluetoothDevice类获取可用的配置文件.

但是,通过BluetoothProfile类中的getDevicesMatchingConnectionStates方法获取BluetoothDevices列表还有很长的路要走.

例如,如果要查找哪个BluetoothDevices支持A2DP,请首先创建自定义BluetoothProfile.ServiceListener

public class cServiceListener implements BluetoothProfile.ServiceListener {

private static final int[] states={ BluetoothProfile.STATE_DISCONNECTING,

BluetoothProfile.STATE_DISCONNECTED,

BluetoothProfile.STATE_CONNECTED,

BluetoothProfile.STATE_CONNECTING};

@Override

public void onServiceConnected(int profile, BluetoothProfile bluetoothProfile) {

List Devices=bluetoothProfile.getDevicesMatchingConnectionStates(states);

for (Blueto

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值