On Tue, Nov 8, 2011 at 2:45 PM, Priyank <priyankvma...@gmail.com> wrote:
> Thanks for the reply. The 2 changes you mentioned made it work.
> But the problem now I am facing is that, I cannot call a method which
> belongs to the main class(BroadcastActivity ) from onReceive() since
> the Receiver1 class is static. Is there any way to deal with this.

Not the way you're going about the problem.

> The reason I can not put the Receiver1 class in a different java file
> is that there are many UI changes I do when I receive the broadcast.

You will not be doing any changes to the UI when you receive the
broadcast. If you wanted to do that, you would not be using a
manifest-registered receiver. Use registerReceiver() in the activity
to register a BroadcastReceiver dynamically; that receiver can then
work with the activity to update the UI.

For example, here is an application that uses ACTION_BATTERY_CHANGED this way:

https://github.com/commonsguy/cw-advandroid/tree/master/SystemEvents/OnBattery

-- 
Mark Murphy (a Commons Guy)
http://commonsware.com | http://github.com/commonsguy
http://commonsware.com/blog | http://twitter.com/commonsguy

Android Training in NYC: http://marakana.com/training/android/

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