Service stopped when the app removes from recent apps list in android

…衆ロ難τιáo~ 提交于 2020-01-07 03:05:41

问题


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



来源:https://stackoverflow.com/questions/34104525/service-stopped-when-the-app-removes-from-recent-apps-list-in-android

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!