0

I have an application that downloads data in a background service and I want to be able to update an activity UI if they are currently running the application or trigger a Notification if they are not.

How do I know if the application is currently in the foreground?

I could register a BroadcastReceiver inner class in the activity and trigger this if its in the foreground otherwise uses notification but I don't know how I can check what action to take.

Thanks for any replies.

Kyros
  • 459
  • 2
  • 5
  • 11
  • This is similar to your issue: http://stackoverflow.com/questions/2282435/inform-activity-from-a-broadcastreceiver-only-if-it-is-in-the-foreground – Brian Driscoll Oct 05 '10 at 16:32

1 Answers1

3

Use an ordered broadcast, with the activity implementing a high-priority BroadcastReceiver and a separate low-priority BroadcastReceiver to raise the Notification. I have a blog post covering this specific topic.

CommonsWare
  • 986,068
  • 189
  • 2,389
  • 2,491