onCharacteristicChanged在Android 5.0中不是回调

onCharacteristicChanged在Android 5.0中不是回调,android,bluetooth,bluetooth-lowenergy,Android,Bluetooth,Bluetooth Lowenergy,在安卓4.3中,onCharacteristicChanged是一个回调函数,但在上面的安卓5.0中,它不是调用函数WriteCharacteristic'和SetCharacteristicNotification'已成功,onCharacteristicWrite'回调已成功。为什么在Android5.0或Android 6.0中不调用它 这是我的通知代码: private void notification(BluetoothGattCharacteristic gattCharacter

在安卓4.3中,onCharacteristicChanged是一个回调函数,但在上面的安卓5.0中,它不是调用函数WriteCharacteristic'和SetCharacteristicNotification'已成功,onCharacteristicWrite'回调已成功。为什么在Android5.0或Android 6.0中不调用它

这是我的通知代码:

private void notification(BluetoothGattCharacteristic gattCharacteristic, String tag) {
    boolean success = mBluetoothGatt.setCharacteristicNotification(gattCharacteristic, true);
    if (success) {
        for (BluetoothGattDescriptor dp : gattCharacteristic.getDescriptors()) {
            if (dp != null) {
                if ((gattCharacteristic.getProperties() & BluetoothGattCharacteristic.PROPERTY_NOTIFY) != 0) {
                    dp.setValue(BluetoothGattDescriptor.ENABLE_NOTIFICATION_VALUE);
                    Log.i(TAG,"notification NOTIFICATION value = "+ Arrays.toString(BluetoothGattDescriptor.ENABLE_NOTIFICATION_VALUE));
                } else if ((gattCharacteristic.getProperties() & BluetoothGattCharacteristic.PROPERTY_INDICATE) != 0) {
                    dp.setValue(BluetoothGattDescriptor.ENABLE_INDICATION_VALUE);
                    Log.i(TAG,"notification INDICATION value = "+ Arrays.toString(BluetoothGattDescriptor.ENABLE_NOTIFICATION_VALUE));

                }
                mBluetoothGatt.writeDescriptor(dp);
                Log.i(TAG, tag + " notification successful");
            }
        }
    }
}
“BluetoothGatt.writeDescriptor(dp)”失败,它是一个异步线程。当线程繁忙时,停止写入描述符。所以我一个接一个地写描述符。没关系