I have an android app that connects to a few classic Bluetooth and BLE devices. Starting from one of the security patch releases of Android 10 I am getting pairing requests on my Android device. Is there a way to automatically accept these requests in code? The BLE devices do not have a pin and only need a certain flow of read and write operations to pair. Right now my write operations are failing unless I wait for the bond state to change to BONDED which happens on accepting the pairing request on the Android device. So far I've tried setPairingConfirmation(true) which does not seem to be working.
Asked
Active
Viewed 675 times
0
-
Unfortunately it is not possible to programmatically accept a pairing request – Martijn van Welie Jul 12 '21 at 19:17
-
@MartijnvanWelie setPairingConfirmation(true) does not work anymore? Any idea when this changed? – farfly Jul 12 '21 at 19:43
-
It probably works but you need the BLUETOOTH_PRIVILEGED permission, which is not possible to get for normal apps. It is for system apps only. – Martijn van Welie Aug 24 '21 at 17:30
1 Answers
1
I guess the idea of pairing is that the user must accept that an "unknown" device being paired to his system. Otherwise different shady apps could just pair devices in the background without the user's consent.
A peripheral that is not meant to be paired to a user should hence not require pairing in the first place, to perform various operations.

Emil
- 16,784
- 2
- 41
- 52