的是Android服务有用的,当我不需要进程间通信? [英] Is Android Service useful when I don't need interprocess communication?
问题描述
看来,当我不需要进程间通信,也几乎没有理由使用服务。我所知道的唯一的原因是这样的:如果我的进程有一个启动的服务,这个过程是不太可能被杀害
It seems that when I don't need interprocess communication, there's almost no reason to use a Service. The only reason I am aware of is this: if my process has a started Service, the process is less likely to be killed.
我可能只是有dontWantToBeKilled()和canBeKilled()方法的实用程序类,这将启动/停止的虚拟服务。除此之外,我不会使用服务。这是正确的?
I could just have a utility class with dontWantToBeKilled() and canBeKilled() methods, which would start / stop a dummy Service. Apart from that, I won't use Services. Is this right?
推荐答案
是的,还有其他的原因。
Yes, there are other reasons.
您的应用程序中,可以通过时,它需要更多的资源,系统杀死一个进程中运行。
Your application runs in a process which can be killed by the system whenever it needs more resources.
根据这的正在运行的服务具有更高的优先级比不是在前台,这意味着系统更可能杀死具有在后台活动多于一个具有在后台运行的服务的应用程序处理的活性
According to this a running service has a higher priority than an Activity that isn't in the foreground, meaning that the system is more likely to kill an application process that has an Activity in the background than one that has a Service running in the background.
有关服务的文档指出:
所以,你可以使用服务来减少你的应用程序被杀害的可能性。
So, you can use Services to decrease the likelihood of your application process being killed.
这篇关于的是Android服务有用的,当我不需要进程间通信?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!