0
votes

I have been reading the Bluetooth documentation on Android's developer site.

I want to pair a Bluetooth device and then connect to it, but I don't want the request dialog to pop up (or even if it does set the pin using some API to dismiss it). I want to do it in Android 4.3+.

So far I see this involving the following steps:

1) App discovers device : use BroadcastReceiver to get BluetoothDevice

2) App pairs the device : uses BluetoothDevice.createBond(), and registers a BroadcastReceiver to get confirmation of pairing completion

3) App connects to device : uses BluetoothDevice.createRfCommSocketToServiceRecord(UUID)

My understanding is that the pop dialog for pairing will be shown to the user after step 2. I know there is a setPin() API (now public) in the BluetoothDevice class.

If I call it right after step 2, will the dialog still appear and wait for user input, or will it appear and then dismiss, resulting in pairing success ?

Also does step 3 involve any input from the user ?

1

1 Answers

0
votes

Step 3 doesn't involve user input.

I've been trying to do exactly the same, I use setPin() and it works, but the user Input dialogue is still there, there is an option to use cancelPairingUserInput but i'm not sure if this is still valid for API19 (that is the one which uses setPin() as far as I know...) or if there is another way to do it.

Hope this helps...