My problem was caused by a timing issue. I was actually reading the characteristic before the device had fully paired. To solve this problem, I added a IntentFilter when I started connection to the device:
IntentFilter filterScan = new IntentFilter();
filterScan.addAction(BluetoothDevice.ACTION_BOND_STATE_CHANGED);
bluetoothReceiver = new BluetoothReceiver();
context.registerReceiver(bluetoothReceiver, filterScan);
and then unregistered at close, of course:
if(bluetoothReceiver != null) {
context.unregisterReceiver(bluetoothReceiver);
bluetoothReceiver = null;
}
And here is the receiver:
private class BluetoothReceiver extends BroadcastReceiver{
@Override
public void onReceive(Context context, Intent intent) {
String action = intent.getAction();
BluetoothDevice deviceIn = intent.getParcelableExtra(BluetoothDevice.EXTRA_DEVICE);
if (deviceIn != null) {
if (deviceIn.equals(device)) {
if (BluetoothDevice.ACTION_BOND_STATE_CHANGED.equals(action)) {
int bondState = intent.getIntExtra(BluetoothDevice.EXTRA_BOND_STATE, BluetoothDevice.BOND_NONE);
if(bondState == BluetoothDevice.BOND_BONDED){
//now start reading
}
}
}
}
}
}
Hope this helps.