我想通过点击按钮停止蓝牙发现过程。我使用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
答案 0 :(得分:0)
我创建了一个新项目来测试cancelDiscovery()
。一旦我们调用此方法,就会广播ACTION_DISCOVERY_FINISHED
。在我的情况下,我使用处理程序重复发现过程,所以我也必须停止它。