Android-Service killed with “no longer want” - how to restart it?

前端 未结 2 858
执念已碎
执念已碎 2020-12-23 17:29

We have a Service that continuously collects sensor data on the phone. This service should run \"forever\", e.g. as long as the user wants, and not be killed by the system.<

2条回答
  •  眼角桃花
    2020-12-23 17:51

    Try overriding the onCreate() method of your service. If the service is killed and then restarted it's onCreate() is called, but not onStart(). So you can, for example, add call to onStart() from onCreate to make it behave like the RunKeeperService.

提交回复
热议问题