I have just been playing around with status bar notifications and am a bit stumped at what to do in the following situation:
I have an activity for displaying messages and a service which polls for new messages. When the service finds a new message it adds a notification to the status bar… all well and good. My question is: When the user is already in the messages activity, I probably don’t want to add anything to the notification bar. I only want to add it if they are not looking at the messages at the time. I would think this is a common problem and am wondering if anyone knows the solution?
Have a static boolean variable in your Activity called
isRunningthat you set false when ever onPause is called, and true whenever onResume is called. It’s simple and elegant 🙂