Android蓝牙配对:如何确保在前对话框中获得蓝牙配对请求而不是通知? [英] Android Bluetooth Pairing: How to make sure to get bluetooth pairing request in the front dialog instead of a notification?

查看:354
本文介绍了Android蓝牙配对:如何确保在前对话框中获得蓝牙配对请求而不是通知?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

此外,如果我收到通知,是否可以通过编程方式单击该通知并将配对请求置于最前面?

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

推荐答案

供解释原因和内容的参考,请在此处查看: 通知栏上的蓝牙配对请求?

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();
}

在尝试配对或连接蓝牙设备之前,请致电feintBluetoothDeviceDiscovery().弹出窗口应显示在前面.

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.

这篇关于Android蓝牙配对:如何确保在前对话框中获得蓝牙配对请求而不是通知?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆