Wow. Quick reply. Thanks.

Ok. So to let the service act on the "broadcast" intents I'll forward
them in the BroadcastReceiver:

public void onReceive (Context context, Intent intent) {
  context.startService(intent.setClass(context, MyService.class));
}

Is that good practice?


On Nov 10, 1:53 am, Mark Murphy <[email protected]> wrote:
> On Tue, Nov 9, 2010 at 7:51 PM, Henrik Lindqvist
>
> <[email protected]> wrote:
> > I've got a IntentService started by an alarm. I also want it to start
> > on other intents, like ACTION_TIME_CHANGED. Do I have to create an
> > BroadcastReceiver that start the service when it receivers the
> > TIME_SET intent, can't the service be started by the intent in the
> > first place. I tried to add <service>/<intent-filter>/<action> but
> > didn't work. Should it?
>
> There are three "channels", if you will, on the Intent message bus:
>
> -- starting activities (Activity)
> -- starting services (Service)
> -- sending broadcasts (BroadcastReceiver)
>
> ACTION_TIME_CHANGED is a broadcast action (as indicated in the docs).
> That can only be received by a BroadcastReceiver. It cannot be
> received by a service.
>
> --
> Mark Murphy (a Commons 
> Guy)http://commonsware.com|http://github.com/commonsguyhttp://commonsware.com/blog|http://twitter.com/commonsguy
>
> Android App Developer Books:http://commonsware.com/books

-- 
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