vic
vic

Reputation: 759

android Bluetooth Pairing request

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

Upvotes: 2

Views: 2898

Answers (2)

Patrick Cho
Patrick Cho

Reputation: 1331

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) {
}

Upvotes: 5

mikey
mikey

Reputation: 36

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

Upvotes: 1

Related Questions