Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android Bluetooth Pairing: How to make sure to get bluetooth pairing request in the front dialog instead of a notification?

Also, If I get a notification, is there a way to click it programmatically and bring the pairing request to to front?

like image 648
Martin Avatar asked Nov 10 '22 05:11

Martin


1 Answers

for reference to explain why and what, please have a look here: Bluetooth pairing request on notification bar?

The solution is quite easy if you know it and if it fits into your application:

private void feintBluetoothDeviceDiscovery() {
    BluetoothAdapter btAdapter = BluetoothAdapter.getDefaultAdapter();
    btAdapter.startDiscovery();
    btAdapter.cancelDiscovery();
}

Call feintBluetoothDeviceDiscovery() before you try to pair or connect your bluetooth device. The popup should appear in the front.

We also had this issue in our automated tests. A pairing request only showing as notifications are a pain there. Thank to a colleague for sharing the code.

like image 200
maze Avatar answered Nov 14 '22 23:11

maze