Android C2DM sleeping phone

爱⌒轻易说出口 提交于 2019-12-07 18:16:37

问题


According to this Android C2DM keeps a socket alive with a heartbeat mechanism, making it able to receive push messages. This made me hope I could deliver messages to sleeping phones with an active wifi connection.

I've made an implementation setting the "delay_while_idle" to '0'. The message is delivered if my phones' screen is powered off, but not if the phone goes to sleep (tested with intervals 20mins, 1-6 hours).

I have acquired a partial cpu lock + a full wifi lock just in case.

Have I simply made something fundamentally wrong or did I misunderstand the C2DM push functionality?

Can I send messages to sleeping phones or not?


回答1:


Using alarmmanager instead of wakelocks could keep your phone alive just enough. See this implementation. Will test a variant of this.



来源:https://stackoverflow.com/questions/4661836/android-c2dm-sleeping-phone

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