蓝牙耳机:getProfileConnectionState始终返回连接状态

时间:2013-07-17 07:49:37

标签: android bluetooth headset

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

    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

0 个答案:

没有答案