簡體   English   中英

Android:從未收到BLE Gatt通知

[英]Android: BLE Gatt Notifications never received

使用的設備:Galaxy S9,Android 8.0。

連接工作正常,但從未調用過回調的onCharacteristicChangedMethod 但是我已經使用setCharacteristicNotification(char, true)注冊了通知。 特征通知代碼:

mBluetoothGatt.setCharacteristicNotification(characteristic, true);
BluetoothGattDescriptor descriptor = characteristic.getDescriptor(UUID.fromString(SampleGattAttributes.CLIENT_CHARACTERISTIC_CONFIG));
descriptor.setValue(BluetoothGattDescriptor.ENABLE_NOTIFICATION_VALUE);
mBluetoothGatt.writeDescriptor(descriptor);

特性配置。 UUID是00002902-0000-1000-8000-00805f9b34fb

向Android清單添加的權限:

<uses-permission android:name="android.permission.BLUETOOTH"/>
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN"/>
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>

我已經閱讀到我需要顯式聲明broadcastReceiver,並在日志中觀察以下消息:

W/BroadcastQueue: Background execution not allowed: receiving Intent

這是問題嗎?如果是的話,我將如何明確聲明此接收者?

由於在動態聲明broadcastReceiver時未關閉該問題,因此在我的項目中未啟用通知,因此已解決了有關后台執行的問題(這是原始查詢)。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM