Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Leaked IntentReceiver in Google Cloud Messaging

I have implemented GCM in my app and I am using GSMRegistrar as suggested here. No I am getting 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 I can understand from this and looking at the code for GSMRegistrar is I need to to call GSMRegistrar.onDestroy(this) but I could not understand where should I call this? Calling in onDestroy() of activity mnp causes it to stop retrying for GSM Registartion

like image 607
Gaurav Agarwal Avatar asked Nov 29 '22 02:11

Gaurav Agarwal


1 Answers

You may use the application context, instead of the activity context. That way the backoff mechanism is not restricted by the activity life cycle.

like image 113
randomuser Avatar answered Dec 04 '22 21:12

randomuser