tags:

views:

37

answers:

2

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.

+1  A: 

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