Start intent service and close app

淺唱寂寞╮ 提交于 2020-01-16 04:11:06

问题


I'm implementing GCM in my app and I start the RegistrationIntentService in the main activity. What happens if I close the app before the intent finishes?

The service takes a few seconds and I need the registration finishes despite the user has closed the app.

This work this way or I have to do something more?

Thanks!


回答1:


Unless the system suddenly kills the application process, the intent will finish, because as a user you don't have direct control over when the app is actually closed (meaning, the process finished). When you "close" the app, you just put the activity in the background and the system will probably shut the process down some time later (see this thread).

I have to do something more?

So no, you should be fine with the standard IntentService - in normal cases it will finish even if the user "closes" the app, and in the case of system deliberately killing your process, there is nothing you can do about it anyway.



来源:https://stackoverflow.com/questions/35524484/start-intent-service-and-close-app

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