How can I call service methods from broadcastReceiver?

by Mark Murphy » Mon, 07 Dec 2009 15:40:12 GMT

Sponsored Links
 > Hello

I would get rid of the broadcast receiver and just have the activity work
with the service.

1. I would not raise a Toast from a BroadcastReceiver.

2. You cannot call new RemoteService() to create an Android service. You
need to call startService() with an appropriate Intent to start up your
RemoteService. And, bear in mind that the service will not be started
until after your onReceive() method returns.

3. You cannot call methods on a service from a BroadcastReceiver very
easily. I would strongly recommend you find some other solution (e.g., put
extras on the Intent you use with startService(), so your service learns
what to do from those extras alone).

You can see an example of a BroadcastReceiver using startService() to
start up a service here: 

Mark Murphy (a Commons Guy) 
Android App Developer Books: 


Other Threads

1. How to Snap a picture of a Layouts contents?


I need to somehow get a drawable of the contents of a Layout, once I
get that "drawable" I want to set it as a background on an empty

How can I go about doing this?


2. Eclipse + cupcake + other android projects in build path = VerifyError

I fixed the problem just by modifying .classpath, AndroidManifest.xml and
adding build.xml

Best Regards

Eric Chen

On Wed, Apr 29, 2009 at 7:52 PM, Guillaume Perrot


3. The android-porting list is now partially moderated.

4. Motorola coming out with Android handsets this year.

5. Could not find MyApp.apk!

6. compiling application with full android source code

7. Date in sms