Update Running Activity from BroadcastReceiver?

by Cormac McCarty » Fri, 27 Feb 2009 01:48:33 GMT

Sponsored Links
 Hi all,

Is it possible to update a currently running activity from a BroadcastReceiver?

I have a BroadcastReceiver that's able to start an activity just fine
from its onReceive method.  But what if the activity is already
running?  How do I let it know that the BroadcastReceiver has some
more data for it?  Do I just start the activity again?  If so, would
that be a new instance of the activity?  What happens to the old one?
If it doesn't create a new instance, does onCreate get called again?
If not, how does the activity know that it's been hit again by the
BroadcastReceiver?  More importantly, in that case, how does the
activity get the data I attached to the intent in the


Update Running Activity from BroadcastReceiver?

by Cory » Fri, 27 Feb 2009 23:07:25 GMT

 I figured it out.

If you have the Activity register the BroadcastReceiver
programatically (ie, not in the manifest file), the Activity can have
a reference to the BroadcastReceiver.  Then you can give the Activity
a listener interface and register it with the BroadcastReceiver.  So
instead of having the BroadcastReceiver fire an Intent, it just calls
the callback on the Activity.  You may have to set up a Runnable and
call runOnUiThread() on the Activity, but it works just fine.



Sponsored Links

Other Threads

1. What is a WeakReference?

Google just posted a new blog post on
I understand the AsyncTask and I'm even using one in a list with
images already.

But I don't understand what a WeakReference is. I gather is is a
garbage collector directive, but I thought I didn't need to manage
garbage collection on Android.

isn't as helpful as I was hoping it would be.


2. Android Frame Buffer Driver mechanism

Hi all,

I want to understand the Android Frame Buffer driver mechanism, can i
find any documents for this as i get lost in the source code, I just
take a look in the source code and see that Android use two frame
buffer to display and flip back and force, i want a deep understand on
this bc i am going to integrate the remote frame buffer in to Android
Thanks advance for your help !

unsubscribe: android-kernel+unsubscr...@googlegroups.com

3. The content of the adapter has changed but ListView did not receive a notification

4. The content of the adapter has changed but ListView did not receive a notification

5. Using AudioRecord.


7. Any cheap solutions of GPS signal simulation?