Bluetooth headset: getProfileConnectionState always returns connection status

I am trying to check if there is a Bluetooth headset connected to the device or not

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)); 

This always returns HEADSET 2 (Connected), Health 0 (disabled) and A2DP 0 (disabled). It does not matter if I have a Bluetooth headset connected or not, the headset connection status is 0 only when bluetooth is turned off.

+4
source share

Source: https://habr.com/ru/post/1491805/


All Articles