I would like to receive an event for detecting whenever bluetooth gets paired or unpaired in my device.
In the beginning i found http://developer.android.com/reference/android/bluetooth/BluetoothServerSocket.html.
I followed this blog : http://android-er.blogspot.co.il/2014/12/make-bluetooth-connection-between.html which is quite usefull, but, isn't detecting when a new connection is made.Needless to say, I have no use for bluetooth implementation, which i'm well aware of :
final BluetoothAdapter.LeScanCallback bleScanCallback = new BluetoothAdapter.LeScanCallback() {
@Override
public void onLeScan(final BluetoothDevice device, final int rssi, byte[] scanRecord) { ... }
}
Any help will be greatly appreciated.
I'm thinking i should find a way to access one of those classes : BluetoothBondStateMachine, BTConnectionReceiver, BluetoothBondStateMachine which will be a nice start, since i can see that in the logcat whenever pairing / unpairing is created, those classes detect it.
Connected to ble device "shine" :07-28 18:05:49.284 8332-8332/? I/BTConnectionReceiver﹕ onReceive(context, Intent { act=android.bluetooth.device.action.ACL_CONNECTED flg=0x4000010 cmp=com.google.android.googlequicksearchbox/com.google.android.search.core.service.BluetoothConnectionReceiver (has extras) }, [BluetoothDevice: address=F2:3F:FB:30:A1:75, alias=null, name=Shine, majorDeviceClass=7936, deviceClass=7936]
07-28 18:05:49.285 8332-8332/? I/BluetoothClassifier﹕ Bluetooth Device Name: Shine
07-28 18:05:49.830 19769-19793/? W/bt_smp﹕ smp_send_id_info
07-28 18:05:49.836 19769-19786/? I/BluetoothBondStateMachine﹕ bondStateChangeCallback: Status: 0 Address: F2:3F:FB:30:A1:75 newState: 2
07-28 18:05:49.838 19769-19787/? I/BluetoothBondStateMachine﹕ Bond State Change Intent:F2:3F:FB:30:A1:75 OldState: 11 NewState: 12
07-28 18:05:49.838 19769-19787/? I/BluetoothBondStateMachine﹕ StableState(): Entering Off State
07-28 18:05:50.564 19769-19793/? E/bt_att﹕ gatt_disc_cmpl_cback() - Register for service changed indication failure
07-28 18:05:51.189 19769-19793/? W/bt_bta_gattc﹕ bta_gattc_explore_srvc no more services found
07-28 18:05:51.191 19769-19793/? I/bt_bta_dm﹕ bta_dm_gatt_disc_result service_id_uuid_len=2