0

I bridged a java module to react native that uses the earphone jack to listen for peripheral devices. The module needs to be destroyed after the app is closed or else it throws NullPointerException when the app is opened again. In its original form, the module is used in an activity and hence the activity's onDestroy method is overridden to destroy the object. In the bridged form, however I use it in a class that extends ReactContextBaseJavaModule. How do i properly implement onHostDestroy() to destroy this listener when the app is closed.

4

1 回答 1

0

可以使用 remove() 删除设备侦听器。This.listenerName.remove() 应该可以完成工作。这取决于您在所需的位置使用它。通常我在从一个组件导航到另一个组件时使用它反应原生.

于 2017-02-28T13:09:02.490 回答