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

∥☆過路亽.° 提交于 2020-08-04 12:29:44

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!