How Can I Display an alert when push notification arrives from C2DM or GCM. Right now I am displaying notifications on status bar. So How can I get a notification as an alert.
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Popping a dialog in the middle of something a user is doing is a wildly user hostile thing to do. What if they’re playing Angry Birds and you’ve just ruined their shot? Only the platform can and should get away with that.
Use the notification area, like Google intended, UNLESS you app currently has control (your activity is in running state). Then just use that activity’s context to pop an
AlertDialog(). You can detect if the activity is running by overridingonResume()andonPause()– anything that happens in between is your activity’s time.An AlertDialog can be popped like this:
For a simple message/Yes/No dialog, an
AlertDialogwould suffice. For more complicated UI, derive a class fromDialogand design your own layout.