5

我正在尝试检查是否有蓝牙耳机连接到设备

    BluetoothAdapter mAdapter;
    mAdapter = BluetoothAdapter.getDefaultAdapter();
    Log.d("TAG","HEADSET: " + mAdapter.getProfileConnectionState(BluetoothProfile.HEADSET));
    Log.d("TAG","HEALTH: " + mAdapter.getProfileConnectionState(BluetoothProfile.HEALTH));
    Log.d("TAG","A2DP: " + mAdapter.getProfileConnectionState(BluetoothProfile.A2DP));

这总是返回 HEADSET 2(已连接)、Health 0(已断开)和 A2DP 0(已断开)。有没有连接蓝牙耳机没关系,耳机连接状态只有在蓝牙被禁用时才为0

4

0 回答 0