What are the advantages and disadvantages of starting a service in different processes?

I want to run a long service in the background in my application. I use the Service for this, but the service has a tag called android:process So my service is similar to ...

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

Question:

So, I want to know about the advantages and disadvantages of starting Service in different processes.

+6
source share
2 answers

Over my head ...

Disadvantages:

  • You must use interprocess communication to talk to her, which is slower than if it were in the same process as the client.
  • Debugging is getting harder because there is now another process that you might need to connect to.
  • If it crashes, it crashes regardless of your main process. One could argue that this is also up. Something to consider.
  • Special care is required in any initialization code, for example, in your application. There will be an instance of the application context for each process. So, for example, if you initialize something like GCM, you probably want to do this only in the main process. (Turning to this, in particular: http://developer.android.com/reference/android/app/Application.html )

Upside potential:

  • The only real potential that I can come up with, and really the only time I used a separate process, is that you get a whole new heap space to work regardless of the main process. Useful if you need this memory for some operation.
+3
source

Con : using android:process=":myprocess" really bad if you want to update values ​​or communicate with the application, none of your values ​​will be updated .
Be careful when using. (It took me 2 days)

Pro : does not block the application during a lengthy process.

+2
source

All Articles