I always receive a weird push when I newly register at the Google Cloud Messaging server

671 views
Skip to first unread message

flames

unread,
Jun 2, 2015, 6:22:47 AM6/2/15
to andro...@googlegroups.com
And this error started showing up for no reason when the app is launched for the first time though i am not sending a push notification.

java.lang.RuntimeException: BroadcastReceiver trying to return result during a non-ordered broadcast
at android.content.BroadcastReceiver.checkSynchronousHint(BroadcastReceiver.java:783)
at android.content.BroadcastReceiver.setResultCode(BroadcastReceiver.java:549)
at valetDroid.parkingMovistar.utils.GcmBroadcastReceiver.onReceive(GcmBroadcastReceiver.java:29)
at android.app.ActivityThread.handleReceiver(ActivityThread.java:2525)
at android.app.ActivityThread.access$1600(ActivityThread.java:159)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1392)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:176)
at android.app.ActivityThread.main(ActivityThread.java:5419)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:525)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1046)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:862)
at dalvik.system.NativeStart.main(Native Method)

Just started to happen 1 week ago without changes in the code, I think it´s related to the new update of google play services.


Liam Byrne

unread,
Jun 2, 2015, 2:16:45 PM6/2/15
to andro...@googlegroups.com
You are getting this error because you are calling setResultCode() in your BroadcastReceiver, which throws this exception for non-ordered broadcasts. This can be easily fixed by checking if the current broadcast is ordered first, e.g.

if (isOrderedBroadcast()) {
    setResultCode(Activity.RESULT_OK);
}

A better solution is to move over to the new GcmReceiver and GcmListenerService as detailed here: https://developers.google.com/cloud-messaging/android/client

The reason your app is getting this broadcast is because GCM detected that after your app was installed, backed up data was restored. As this may include registration tokens, we send a broadcast telling your app to get new registration tokens as the backed up ones will not work.

If you use the new APIs, this will cause your InstanceIdListenerService implementation's onTokenRefresh() method to be called, where your app should obtain all its tokens again. If you are writing your own BroadcastReceiver, these messages can be detected as they will have "from": "google.com/iid" in the intent extras.

flames

unread,
Jun 25, 2015, 10:11:05 AM6/25/15
to andro...@googlegroups.com
Thanks for your response, with the first solution I fixed it.
Reply all
Reply to author
Forward
0 new messages