Getting notification endlessly from GCM Intent Service in android

[亡魂溺海] 提交于 2019-12-06 08:14:02

Okay. So what is happening with your code is that you are sending a broadcast to your Receiver as well forcing the onHandleIntent to be invoked again, which in result calls the updateActivity method, which again broadcasts and loop continues endlessly.

In your updateMyActivity method, please change this:

Intent intent = new Intent("com.google.android.c2dm.intent.RECEIVE");

to

Intent intent = new Intent("myMessage");

The culprit here is

com.google.android.c2dm.intent.RECEIVE

which calls the onHandleIntent when broadcasted.

Also, in your onResume method of the activity, please change the TAG to myMessage:

getActivity().registerReceiver(mMessageReceiver, new IntentFilter("myMessage"))
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!