Google Cloud Messaging - messages sometimes not received until network state changed

后端 未结 5 1810
我寻月下人不归
我寻月下人不归 2020-11-28 04:40

While working on a little project that integrates with GCM, I\'ve stumbled across a bit of a strange issue.

Some times when I start watching the log to see if messag

5条回答
  •  天涯浪人
    2020-11-28 05:24

    in the GCMIntentSevice class ,when you receive message from server ,onMessage method gets called so at that time you can do something like...

    PowerManager pm = (PowerManager) getApplicationContext()
                    .getSystemService(Context.POWER_SERVICE);
            WakeLock wakeLock = pm.newWakeLock(
                            (PowerManager.SCREEN_BRIGHT_WAKE_LOCK
                                    | PowerManager.FULL_WAKE_LOCK | PowerManager.ACQUIRE_CAUSES_WAKEUP),"TAG");
            wakeLock.acquire();
    

    and you have to add

    permission in you manifest file..

    this should do the trick...

提交回复
热议问题