Service stopped when the app removes from recent a

2019-08-26 03:06发布

问题:

In my application I am using service to run background services continuously even the app removes from recent apps list. But the service stopped if I remove the app from recent apps list. Can any one gives me the solution?

Thanks, Sekhar

回答1:

you have to make and show a notification until your service is running, use below code :

 startForeground(id, notify.build());

for more information check example project in here . or maybe your problem is like that .

good luck.



回答2:

Start service by returning START_REDELIVER_INTENT onStartCommand of service to continuously run your service see my answer here.

And if you never have worked on service before then i suggest you to read Service documentation first so you will get more idea and clarification : refer this doc