启动intent服务并关闭应用程序 [英] Start intent service and close app

查看:128
本文介绍了启动intent服务并关闭应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在应用程序中实施GCM,并在主要活动中启动RegistrationIntentService。
如果我在意图完成之前关闭应用程序,会发生什么情况?

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.

谢谢!

谢谢!

推荐答案

除非系统突然杀死了应用程序进程,否则意愿将完成,因为作为用户,当应用程序是实际上关闭了(意思是,过程完成)。当您关闭应用程序时,您只需将该活动置于后台,系统可能会在一段时间后关闭该过程(请参阅
$ b

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?

所以 no ,您应该对标准的 IntentService - 在正常情况下,即使用户关闭应用程序也会结束,而在系统故意杀死进程的情况下,无论如何您都无法做到这一点。

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.

这篇关于启动intent服务并关闭应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆