How do I set up a GCM BroadcastReceiver when my app has multiple activities?
I'm developing an application that is to receive push notifications using
Google Cloud Messaging. The problem is that I'm running registerReceiver()
in an "SplashActivity" that I use for doing some initial work, fetching
and registering at the GCM server. The problem is that when the activity
is done doing this, it opens the MainActivity using an Intent, and I get
the error message:
Activity <package>.SplashActivity has leaked IntentReceiver
<package>.GCMMessageReceiver@40ed1c38 that was originally
registered here. Are you missing a call to unregisterReceiver()?
What to do here? I don't want to unregister the IntentReceiver when
leaving the activity, as I want the app to keep receiving push
notifications (even when closed). What's the recommended way to do this?
Thanks in advance :)
No comments:
Post a Comment