There's an alternative way of handling this that doesn't require opening an Activity.
The new Android Design guide is a good reference for this. Although the existing Developer Guide conflates the two, dialog boxes and notifications are fundamentally different UI experiences. It's important to choose the right one, based on the UI situation at the moment. A dialog is an *alert*, which brings attention to a situation in the currently-running activity. A Toast can also be an alert. In general, you should reserve Toasts for informative messages that confirm a user action. A dialog box is better suited to unusual conditions that the user should consider before moving on to another operation. You should use both of them with a bit of reserve. When possible, anticipate what the user would do next, and do it. For example, don't ask users if they want to make another move in a game if you already know that they can't. This is just annoying. A *notification* is a report from some part of an application that is not in the foreground, which sounds like the situation the OP is encountering. Notifications are displayed in the status bar. You can set the notification so that the user can remove it from the status bar by clicking it or sliding it. You can also set the notification so that it can only be removed by an application. One of these is what the OP is looking for. You should handle C2DM broadcasts in the background, in a service. The service can send a notification to the status bar. It could also send an intent to an Activity, but I don't think that's necessary. Anything related to communications between the network and your app should be done in the background. Of course, one should *never* pop an Activity into the foreground. Make the notification, then let the user decide what to do. If you think about it, all of the default applications that come with Android do this. BTW, handling notifications this way has nothing to do with C2DM. Anything that's not of immediate interest to the user should happen in the background, and any information that comes from the background should go into a notification. On Friday, March 23, 2012 4:31:33 PM UTC-7, PinkFluffyBunny wrote: > > Hi friends, > > I have implemented push notification for my Application using c2dm,but > when I send a notification to the application, I need to open the app > to see the notification alert dialog box. > If an push notification is sent when the application is closed or > minimized (running in background) then the notification alert will not > pop up till we open the application window. > > I want the notification to pop up even when the app is running in the > background or is stopped. It can pop the alert as a banner at the top > that stays for sometime and goes away or it can be a alert dialog box > that needs to be dismissed. > > Are there any parameters specific in the payload or header that need > to be specified to achieve this? > > How to acheive this ??? Please help! > > Thanks! > > -- > Thanks , > Vani -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/android-developers?hl=en

