问题
Also, If I get a notification, is there a way to click it programmatically and bring the pairing request to to front?
回答1:
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.
来源:https://stackoverflow.com/questions/32468062/android-bluetooth-pairing-how-to-make-sure-to-get-bluetooth-pairing-request-in