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

后端 未结 10 806
感情败类
感情败类 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

    on the service's startCommand method return START_STICKY. generally it tell the OS to start the service when it is killed.

提交回复
热议问题