On Thu, Mar 19, 2009 at 7:33 AM, Hans <hkess...@gmail.com> wrote:

> > Services are just completely different from receivers, which are
> different
> > from activities.  They don't receive any broadcasts at all.
> They certainly do when you register for them dynamically.
>

Seriously, they don't.  sendBroadcast() will never ever reach a Service.
When you use registerReciever(), you are creating a dynamic
BroadcastReceiver and delivery is going there; the Service component is not
involved at all.


> So - If I have a service that I want to run when certain things
> happen, just for an example I want it to run when someone clicks
> 'share' on the photo viewer menu.
> Presuming that service is not running, putting the proper intent
> filter in the service's manifest won't make a difference because
> services are never evaluated for intents, but a running service with a
> broadcast receiver inside of it would have its broadcast receiver
> evaluated, correct?


Again, these are three completely different things.  When share is clicked,
startActivity() is called.  The ONLY thing that will happen as a result of
this is an activity being started, so you simply must have an activity
component that will handle the share intent.

Once you are in your activity, you can start your service or so whatever
else you want.


> I presume that if you want a service started up because of a standard
> broadcast message your service's package would also contain a
> broadcast receiver that would actually be what was triggered and it
> would in turn start the service, yes/no?


Correct.


> So, to sum up, unless an intent is sent via broadcast, a running
> service has no approach to receive intents other than from binds and
> starts/stops, correct?


That makes it sound complicated. :)  startActivity -> Activity, startService
-> Service, sendBroadcast -> BroadcastReceiver.  Just don't think of Intent
as a generic message system where all of them are routed through one common
channel.  Intent is a primitive data structure with standard semantics for
declaring and matching a simple language, which is used in various places to
build specific routing facilities.

-- 
Dianne Hackborn
Android framework engineer
hack...@android.com

Note: please don't send private questions to me, as I don't have time to
provide private support.  All such questions should be posted on public
forums, where I and others can see and answer them.

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

Reply via email to