ailinykh wrote:
> Hello, everybody!
> Android has such concept as a Service. It makes sense for interprocess
> communication.
> But if I need this service from Activities running in the same process
> regular singleton seems to be more convenient.
> No need to register, to bind.  Are there any benefits to use service
> in the same process?

Using a service gives you:

1. Less chance of garbage collection problems from failing to null out
the singleton.

2. Automatic shutdown (versus no automatic shutdown with a singleton)

3. A Context (Service extends Context), whereas an arbitrary singleton
will not be, and you need a Context a lot of the time

I'm sure I could think of other reasons, but that's what the first 30
seconds of pondering turned up.

-- 
Mark Murphy (a Commons Guy)
http://commonsware.com | http://twitter.com/commonsguy

Android Training in NYC: 4-6 June 2010: http://guruloft.com

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

To unsubscribe, reply using "remove me" as the subject.

Reply via email to