在这里得到了很多答案,我可以在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