I'm building an action which utilizes Google Cloud Messaging for receiving push notifications.
This involves a couple notable components, namely:
- A
WakefulBroadcastReceiver
to receive the message from GCM.
- An
IntentService
to be notified when a GCM event is received.
As I'm sure is the case for many applications, I'd like to take a different approach for when the application has an activity in the foreground vs. when the application does not have an application in the foreground.
I'd like to post a notification to the notification drawer if the application is not active, and simply forward the event onto the foreground activity if the application is active.
Is there a design pattern for this? How should I go about determining if the app is in the foreground vs. the background?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…