Android 5.0.1 Nexus 9在蓝牙列表中未显示已连接的设备
我有一个蓝牙耳机设备连接到运行Android 5.0.1的Nexus 9 我的应用程序正在运行以下代码,我在其中调用getA2dpConnectedDevice检查A2DP状态。我预计,由于应用程序设备应该连接到耳机,BluetoothProfile.ServiceListener.onServiceConnected会启动,但不会启动Android 5.0.1 Nexus 9在蓝牙列表中未显示已连接的设备,android,bluetooth,android-5.0-lollipop,a2dp,Android,Bluetooth,Android 5.0 Lollipop,A2dp,我有一个蓝牙耳机设备连接到运行Android 5.0.1的Nexus 9 我的应用程序正在运行以下代码,我在其中调用getA2dpConnectedDevice检查A2DP状态。我预计,由于应用程序设备应该连接到耳机,BluetoothProfile.ServiceListener.onServiceConnected会启动,但不会启动 private void getA2dpConnectedDevice() { // Establish connection to the proxy
private void getA2dpConnectedDevice() {
// Establish connection to the proxy.
mBluetoothAdapter.getProfileProxy(this, mA2dpProfileListener,
BluetoothProfile.A2DP);
logAndPostMessage( "Requesting A2DP connection status");
}
private BluetoothProfile.ServiceListener mA2dpProfileListener = new BluetoothProfile.ServiceListener() {
public void onServiceConnected(int profile, BluetoothProfile proxy) {
if (profile == BluetoothProfile.A2DP) {
mBluetoothA2dp = (BluetoothA2dp) proxy;
ArrayList<BluetoothDevice> a2DPdevices = (ArrayList) mBluetoothA2dp
.getDevicesMatchingConnectionStates(new int[] { BluetoothA2dp.STATE_CONNECTED });
// if any connected devices, should only be one
if (a2DPdevices.size() > 0) {
addDeviceToDeviceMap(a2DPdevices.get(0), null);
// post connected msg
logAndPostMessage( "A2DP is connected. Fired A2DPStatusUpdate event");
post(new A2DPStatusUpdate(a2DPdevices.get(0),
BluetoothA2dp.STATE_CONNECTED));
getHeadsetConnectedDevice();
}
}
}
我认为上面的代码应该有效,这有问题吗
奇怪的是,也许Android中存在问题的真正线索是,尽管状态栏中的蓝牙图标表示耳机已连接,但当我进入蓝牙设置屏幕时,我根本看不到耳机
任何智慧的话语都将被感激