什么是运行在不同势过程中的服务的优势和劣势? [英] What are the Advantages and Disadvantages of running a service in diffrent process?

查看:127
本文介绍了什么是运行在不同势过程中的服务的优势和劣势?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想运行在我App.so我使用服务的这一点,但在服务中有被称为标签后台长时间运行的服务安卓过程所以,我的服务是一样..

I want to run a long running Service in the background in my App.so i am using Service for that but in the service there is tag called android:process So my service is like..

<service
        android:name="com.purpleshade.services.ApplicationService"
        android:process=":myprocess">

问::

所以我想了解的优势,并在不同的进程中运行的服务的缺点。 如果您有关于我的问题有任何怀疑,让我知道。

So i want to know about the Advantages and disadvantages of running a Service in different Process. If you having any doubts about my question let me know..

推荐答案

关闭我的头顶......

Off the top of my head...

缺点:

  • 您必须使用进程间通信来说话吧,这比如果它是在同一个进程中的客户端的速度较慢。
  • 在调试变得更加困难,因为现在有一个不同的过程中,你可能需要重视。
  • 如果它崩溃了,它独立于崩溃的主要过程。可能有人会说,这是一个颠倒过,但。要考虑的事情。
  • 需要特别小心,在任何初始化code,如在你的应用程序实例。会有应用上下文为每个过程的一个实例。因此,举例来说,如果你初始化像GCM,你可能希望确保只有这样做的主要过程。 (参照这一点,具体是: http://developer.android.com/reference/安卓/ APP / Application.html
  • You have to use interprocess communication to talk to it, which is slower than if it were in the same process as the client.
  • Debugging becomes more difficult, as now there is a different process you potentially need to attach to.
  • If it crashes, it crashes independently of your main process. One might argue this is an upside too though. Something to consider.
  • Special care is needed in any initialization code, such as in your Application instance. There will be an instance of the Application context for each process. So, for example, if you are initializing something like GCM, you probably want to make sure only doing so in the main process. (Referring to this, specifically: http://developer.android.com/reference/android/app/Application.html)

潜在上升空间:

  • 唯一真正的上攻我能想到的,真是我用一个单独的进程,唯一的一次是,你得到一个全新的堆空间与主流程的独立工作。有用的,如果你需要这个存储一些操作。

这篇关于什么是运行在不同势过程中的服务的优势和劣势?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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