2
votes

Could you help me? How could I check if user denyed bluetooth pairing request?

2

2 Answers

5
votes

As soon as the user press Cancel on the Bluetooth Pairing Request Screen,

intent with action

android.bluetooth.BluetoothDevice.ACTION_BOND_STATE_CHANGED

is fired, and inside it, bundle with int key

android.bluetooth.BluetoothDevice.EXTRA_BOND_STATE

has value

android.bluetooth BluetoothDevice.BONE_NONE

For example, after registering broadcast receiver for the action, get int value like below. Then you will know if user pressed cancel on the pairing screen.

if (intent.getExtras().getInt(BluetoothDevice.EXTRA_BOND_STATE) == BluetoothDevice.BOND_NONE) {
}
1
votes

you can't easily right now. Because the platform hides this from you the only option is to check the bonded devices list before and after