android - Knowing if activity is running on foreground or background -


i use sounds notify user of events. however, not want app notify user sounds if activity not on foreground.

how can check if app running on background or not?

expanding on mco's answer, gcmintentservice needs trigger work in foreground activity of yours, if have foreground activity. typically, setting activities respond sort of message in onresume() , removing in onpause().

"some sort of message" be:

  • an intent sent via localbroadcastmanager
  • an intent sent via classic sendbroadcast()
  • a message via message bus, otto
  • etc.

Comments

Popular posts from this blog

.htaccess - First slash is removed after domain when entering a webpage in the browser -

Automatically create pages in phpfox -

c# - Farseer ContactListener is not working -