Dam
Dam

Reputation: 231

Android : GCMIntentReceiver make a notification unless an activity is running

So in my application, the user is on some kind of a wait screen and the server may push him result in a few second or in a few minutes.

So I would like the GCMIntentReceiver to check if an activity is running. If it is, I would like to start an other activity. If it's not, it should make a Notification.

But I don't know how to do that ^^

Upvotes: 0

Views: 188

Answers (1)

CommonsWare
CommonsWare

Reputation: 1006564

Step #1: Have your activity implement a BroadcastReceiver for some custom action string, registered with a high-priority IntentFilter, where you update your UI and call abortBroadcast().

Step #2: Have another BroadcastReceiver, in the manifest, for the same custom action string, where you raise the Notification.

Step #3: Send that broadcast from your GCMIntentReceiver.

Upvotes: 1

Related Questions