If you are looking for whether the device is a โconnectionโ then you need the android.bluetooth.adapter.action.CONNECTION_STATE_CHANGED file
However, this does not start when the device is STATE_CONNECTED. So I did when the state connects to send the broadcast in a few seconds.
if (bluetoothAdapter .getProfileConnectionState(BluetoothProfile.HEADSET) == BluetoothProfile.STATE_CONNECTING || bluetoothAdapter .getProfileConnectionState(BluetoothProfile.A2DP) == BluetoothProfile.STATE_CONNECTING) { final Handler handler = new Handler(); handler.postDelayed(new Runnable() { @Override public void run() { if (bluetoothAdapter .getProfileConnectionState(BluetoothProfile.HEADSET) != BluetoothProfile.STATE_CONNECTING || bluetoothAdapter .getProfileConnectionState(BluetoothProfile.A2DP) != BluetoothProfile.STATE_CONNECTING) { context.sendBroadcast(new Intent( BluetoothAdapter.ACTION_CONNECTION_STATE_CHANGED)); } } }, 2000);
Kind of hacks, so I posted this issue in the Android tracker. http://code.google.com/p/android/issues/detail?id=25957
Archimedes trajano
source share