I'm using C2DM the first time and I'm looking for a general advice how I can achieve the following: Upon receiving a C2DM messages I decide: - if the application is upon the current activity will display an "alert popup". - if the application is not open I'd like to send a message to the notification bar (similar to new emails, sms, twitter etc.)
We have a GlobalBroadcastReceiver extends BroadcastReceiver
which implements public void onReceive(Context context, Intent intent)
. This is the only receiver registered in AndroidManifest.xml
.
So basically all our broadcasts are piped through this receiver and the first scenario is no problem.
However I'm, wondering how to tackle the second problem. How can I make sure I receive a C2DM.RECEIVE broadcast even when my application is closed and then: how can I notify the user about the incoming data?
I'm super confident there are already a lot of solutions out there but since I couldn't find them I think I'm just missing something of the bigger picture.