tags:

views:

45

answers:

1

Hope someone can help me out here. I will try to be concise!

I have a widget which starts a service. The service registers two broadcast receivers. I would like to send back intents from the receivers to the service, so that the service can react.

I believe I read somewhere that 'starting' the service multiple times works, e.g. do the following in the receivers:

serviceIntent.setAction("me.SERVICE");
intent.putExtra("me.SERVICE", somedata);
context.startService(serviceIntent);

I remember reading (on some blog) that this won't start a new service, but will simply pass the intent to the already running service. Is this correct? Is it a bad way of doing it? Is there a better way?

Thanks very much!

Jack

A: 

Yes, I've used that approach in a pre-2.0 app.

Justin
Thanks Justin! How about post 2.0? Will it work?
Jack
It will work, but services changed. See here: http://developer.android.com/intl/de/reference/android/app/Service.html ; Specifically, `onStartCommand(android.content.Intent, int, int)`
Justin