How to stop Android service when app is closed

前端 未结 3 1299
情深已故
情深已故 2021-02-01 03:52

I\'m trying to keep service running continously until user close app.

I\'m using startService() method from onCreate() method of my main activi

3条回答
  •  孤城傲影
    2021-02-01 04:19

    Set the below attribute in your service tag in the manifest file,

    
    

    adding this will call the ondestroy() of the service when the task is removed (app closed from recent apps list).

提交回复
热议问题