解锁屏幕后如何重启Android应用

时间:2019-11-21 16:23:25

标签: android react-native

我有一个使用paho mqtt(反应本机模块)的react本机应用程序,问题是当屏幕锁定时,该服务会死。我不是Android开发人员,但我读到的问题是打do模式会杀死所有人,几分钟后我的paho服务就会死掉。

我阅读了这个问题https://github.com/eclipse/paho.mqtt.android/issues/226,并测试了此处给出的解决方案,但在android> 8中,该解决方案不再起作用。

我认为2种可能的解决方案:

1. Run service again after unlock the screen (dunno how to do this for
android >8).
2. Restart the app after unlock the screen (Searching for how detect that the screen is unlock in react native).

如果有人知道如何处理此解决方案或其他解决方案。

1 个答案:

答案 0 :(得分:0)

对于Android本机,您可以使用Service

A service is simply a component that can run in the background, even when the user is not interacting with your application, so you should create a service only if that is what you need.

我知道您使用的是react-native,但希望该信息会提供一些提示。

相关问题