【问题标题】:Unsubscribe notification退订通知
【发布时间】:2018-03-09 15:33:07
【问题描述】:

在按钮的帮助下,用户可以接收特性通知。将执行以下代码:

connection.setupNotification(setDescriptorEnableNotification(tmpCharacterostoc, connection))
  .flatMap(notificationObservable -> notificationObservable)
  .observeOn(Schedulers.io())
  .subscribeOn(Schedulers.io())
  .subscribe(bytes -> 
    //data processing
  );

如果用户再次点击按钮,通知应该被取消订阅,这样就不会收到任何通知。

我该怎么做?

我尝试将描述符的值设置为BluetoothGattDescriptorDISABLE_NOTIFICATION_VALUE 但它不起作用。

【问题讨论】:

    标签: bluetooth-lowenergy rx-android rxandroidble


    【解决方案1】:

    subscribe 方法返回一个订阅,持有它的实例,当你不再对通知感兴趣时,只需调用它的“取消订阅”。

    图书馆将为您禁用通知。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-01-11
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多