问题描述
根据的Android C2DM保持插座活着有心跳机制,使得它能够接收推送消息。这使我希望我可以用一个积极的WiFi连接睡觉手机传递消息。
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.
我做了一个实现设置delay_while_idle为0。如果我的手机的屏幕已关闭的消息传递,但如果手机进入睡眠状态(与间隔20分钟,1-6小时测试)。
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).
我已经获得了部分CPU锁+以防万一一个完整的无线网络锁。
I have acquired a partial cpu lock + a full wifi lock just in case.
有我只是使某种根本性错误还是我误解了C2DM推送功能?
Have I simply made something fundamentally wrong or did I misunderstand the C2DM push functionality?
我可以发送邮件到睡觉的手机不?
Can I send messages to sleeping phones or not?
推荐答案
使用alarmmanager而不是wakelocks的可以保持您的手机活着刚刚够。看到这个。将测试这种变体。
Using alarmmanager instead of wakelocks could keep your phone alive just enough. See this implementation. Will test a variant of this.
这篇关于C2DM的Android手机睡眠的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!