On Jul 6, 1:28 pm, Mike Hearn <[email protected]> wrote:
> First and most important question - do you really need a service at
> all? Many apps use services but don't actually need to run all the
> time. Using a service is like a tax on your user. It's currently
> invisible but it won't always be that way: expect your users to start
> asking questions at some point if/when Android makes resource
> consumption of apps more visible.
>
Yes. I absolutely need a background service since I'm doing something
similar to a music player. :)

> Now how to sync state between the activities and the services.
>
> Remember that a service is just an object representing a lifecycle
> construct. It exists in the same process that your activities do, so
> they can communicate in the same way any two Java objects would
> communicate - via direct method calls, for instance. It's perfectly OK
> to use the "local service" idiom that is shown in the API samples to
> bind to a service and then cast the result to the object itself. Or if
> started using an intent, you can just stuff a reference to "this" into
> a static field.
>
> As to using intents, you don't have to do this. You can just keep
> track of what the service is meant to do in a file, a database, or
> whatever else is convenient.
>
I agree totally, but my problem is that my service will most likely be
used by other applications. There could be three (or more) completely
different applications using the service at the same time (a standard
UI doing one type of visualization and another app doing a different
visualization and a homescreen widget, all in different .apk).

So the question remains. If I need to support third-party integration,
is a service (published as an AIDL file) better than Intents? And if
using Intents, is it better to use sticky intent or should I send very
frequent "normal" broadcast intents from the service to signal its
state?

Thanks,
Erik
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to