Restart the service even if app is force-stopped and Keep running service in background even after closing the app How?

前端 未结 8 572
陌清茗
陌清茗 2020-11-30 02:24

I am trying to run a service in the background. What my app does is when user checks checkbox then service starts and when it is unchecked service is stopped. Which is worki

8条回答
  •  一生所求
    2020-11-30 02:53

    You can try to restart service on onDestroy event of service. Use some flags to find if service is closed by the User or its force closed.

    Note that there is not guarantee that onDestroy will be called everytime.

提交回复
热议问题