Android取消发现蓝牙不起作用

发布于 2024-11-16 22:38:09 字数 753 浏览 5 评论 0原文

我想通过单击按钮来停止蓝牙发现过程。我使用 btAdapter.cancelDiscovery(),但我的应用程序仍然扫描设备。我已将 BLUETOOTH_ADMIN 权限放入清单中。我在这里错过了什么吗?

编辑:来自 Logcat 的帖子

DEBUG/TAG(2901): stop Discovery
ERROR/BluetoothEventLoop.cpp(98): event_filter: Received signal org.bluez.Adapter:PropertyChanged from /org/bluez/2664/hci0
ERROR/BluetoothService.cpp(98): stopDiscoveryNative: D-Bus error in StopDiscovery: org.bluez.Error.Failed (Invalid discovery session)
INFO/DTUN_CLNT(2664):     Client calling DTUN_METHOD_DM_START_DISCOVERY (id 2)
INFO/(2649): DTUN_ReceiveCtrlMsg: [DTUN] Received message [BTLIF_DTUN_METHOD_CALL] 4354
INFO/(2649): handle_method_call: handle_method_call :: received DTUN_METHOD_DM_START_DISCOVERY (id 2), len 0

I want to stop Bluetooth discovery process by a button click. I use btAdapter.cancelDiscovery(), but my app still scans for devices. I already put BLUETOOTH_ADMINpermission in manifest. Do I miss something here?

Edit: Post from Logcat

DEBUG/TAG(2901): stop Discovery
ERROR/BluetoothEventLoop.cpp(98): event_filter: Received signal org.bluez.Adapter:PropertyChanged from /org/bluez/2664/hci0
ERROR/BluetoothService.cpp(98): stopDiscoveryNative: D-Bus error in StopDiscovery: org.bluez.Error.Failed (Invalid discovery session)
INFO/DTUN_CLNT(2664):     Client calling DTUN_METHOD_DM_START_DISCOVERY (id 2)
INFO/(2649): DTUN_ReceiveCtrlMsg: [DTUN] Received message [BTLIF_DTUN_METHOD_CALL] 4354
INFO/(2649): handle_method_call: handle_method_call :: received DTUN_METHOD_DM_START_DISCOVERY (id 2), len 0

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

多彩岁月 2024-11-23 22:38:09

我创建一个新项目来测试 cancelDiscovery()。一旦我们调用此方法,就会广播 ACTION_DISCOVERY_FINISHED。就我而言,我使用处理程序来重复发现过程,因此我也必须停止它。

I create a new project to test cancelDiscovery(). Once we call this method, ACTION_DISCOVERY_FINISHED is broadcasted. In my case, I use handler to repeat the discovery process, so I have to stop it as well.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文