Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Double gcm notifications

Tags:

android

I'm testing how to use gcm today. It works ok but I get double notifications.

What I mean about double notifications is few minutes after the notification came, there's second notification with exact same content as the first.

I'm testing the notification using GCM with PHP (Google Cloud Messaging)

I don't know where I'm going wrong.. I'm testing using emulator and a real device This is the logcat debug

02-27 16:05:36.192: V/GCMBroadcastReceiver(513): onReceive: com.google.android.c2dm.intent.RECEIVE
02-27 16:05:36.192: V/GCMBroadcastReceiver(513): GCM IntentService class: mypackage.GCMIntentService
02-27 16:05:36.201: V/GCMBaseIntentService(513): Acquiring wakelock
02-27 16:05:36.221: V/GCMBaseIntentService(513): Intent service name: GCMIntentService-DynamicSenderIds-2
02-27 16:05:36.312: V/GCMBaseIntentService(513): Releasing wakelock

.
.
.

02-27 16:11:14.282: V/GCMBroadcastReceiver(513): onReceive: com.google.android.c2dm.intent.RECEIVE
02-27 16:11:14.282: V/GCMBroadcastReceiver(513): GCM IntentService class: mypackage.GCMIntentService
02-27 16:11:14.291: V/GCMBaseIntentService(513): Acquiring wakelock
02-27 16:11:14.302: V/GCMBaseIntentService(513): Intent service name: GCMIntentService-DynamicSenderIds-3
02-27 16:11:14.402: V/GCMBaseIntentService(513): Releasing wakelock
like image 311
user1912180 Avatar asked Feb 27 '13 09:02

user1912180


1 Answers

Verify that you register your BroadcastReceiver once and only once, because it fires for every time that you register your BroadcastReceiver. You will get problems if, for example, you register it in your onResume method of your Activity but you do not unregister it in your onPause method.

like image 184
Martijn de Milliano Avatar answered Sep 22 '22 10:09

Martijn de Milliano