How to automatically restart a service even if user force close it?

后端 未结 10 836
感情败类
感情败类 2020-11-27 11:19

I want a service to run all the time in my application. So I want to restart it even if it is force closed by user. There is definitely a way to do it as apps like facebook

10条回答
  •  夕颜
    夕颜 (楼主)
    2020-11-27 11:56

    If the situation allows to use 'root' it's usually possible to implement Humpty-Dumpty paradigm.

    Your application (1st) installs another application (2nd, taking APK from assets) and runs the service of the 2nd app. 2nd app's service bind to the 1st app service and rebinds when disconnected. The 1st app does the same.

    Sure it will not help when all apps are killed by some Free RAM or similar application but when Android kills either of those two, the other one will restart its counterpart.

提交回复
热议问题