BluetoothGatt.Connect 在 phone 不充电时不工作
BluetoothGatt.Connect not working when phone is not charging
我构建了一个前台服务和计时器,它会每 45 秒向远程设备发送一些消息。我真的确定服务正在运行,断点也停在 BluetoothGatt.Connect() 但 OnConnectionStatusChanged 在 phone 未充电时从未触发。我不知道这是 Android 限制还是制造商限制。
有人遇到同样的问题吗?
我解决了,只需要在主线程中调用BLE方法即可。
Handler handler = new (MainLooper);
handler.post(()=>{gatt.Connect();});
我构建了一个前台服务和计时器,它会每 45 秒向远程设备发送一些消息。我真的确定服务正在运行,断点也停在 BluetoothGatt.Connect() 但 OnConnectionStatusChanged 在 phone 未充电时从未触发。我不知道这是 Android 限制还是制造商限制。
有人遇到同样的问题吗?
我解决了,只需要在主线程中调用BLE方法即可。
Handler handler = new (MainLooper);
handler.post(()=>{gatt.Connect();});