Skip to content Skip to sidebar Skip to footer

Android: Context Has Some Problem When Displaying Push Notification Using C2dm

I am trying to display push notification messages using C2DM. If it is a Toast message, then it is showing fine. But when I try for Status Bar Notification, or some AlertDialog it

Solution 1:

For one thing, static variable with the context is NOT the way to go. C2DM subsystem is capable of starting your app process when it's not running without starting the main activity. So the static var won't be initialized.

In my experience, the context that you get via onReceive() is perfectly fine. Status bar notifications, however, are notoriously picky and don't throw exceptions in case of subtle errors. I suggest you debug those from the activity (just pop one up in onCreate, for example), then move the code into the C2DM receiver.

Is the image R.drawable.logo actually present in the project? I had a frustrating debug session once that was about a missing notification icon...

Post a Comment for "Android: Context Has Some Problem When Displaying Push Notification Using C2dm"