IntentReceiver Penetration in Google Cloud Messaging

I have implemented GCM in my application and I am using GSMRegistrar as suggested. No. I get an error in logcat

7-02 23:35:15.830: E/ActivityThread(10442): Activity com.abc.xyz.mnp has leaked IntentReceiver com.google.android.gcm.GCMBroadcastReceiver@44f8fb68 that was originally registered here. Are you missing a call to unregisterReceiver()?

What can I understand from this and looking at the code for GSMRegistrar, I need to call GSMRegistrar.onDestroy(this), but I could not figure out where I should call it? An onDestroy()activity call mnpcauses it to stop retrying forGSM Registartion

+4
source share
3 answers

You can use the application context, not the activity context. Thus, the delay mechanism is not limited to the activity life cycle.

+12
source

onDestory() , GCM.

, , . , . , GCMBroadcastReceiver , .

: GCM, :

  • GCM , .
  • GCMRegistrar.onDestroy() onDestroy(), Android, , .
  • - # 2 , , , GCMRegistrar.register, . , .
  • # 3, , , GCM. , , , , .

, №3 , GCM SERVICE_NOT_AVAILABLE. , .

+8

you need to destroy the GCMRegistrar in the onDestroy method of the activit class

        unregisterReceiver(receiver);
        GCMRegistrar.onDestroy(this);
+2
source

All Articles