开发者

Network access when the Android phone is asleep

开发者 https://www.devze.com 2022-12-24 16:39 出处:网络
I\'m using a combination of alarm (set with AlarmManager) and background service to periodically synchronize data in my application.

I'm using a combination of alarm (set with AlarmManager) and background service to periodically synchronize data in my application.

The only problem I have is that when sleep policy terminates Wi-Fi connection the synchronization no longer works.

Is there a way to "wake up" the Wi-Fi conn开发者_StackOverflow社区ection that has been put to sleep? GMail somehow manages to do that because it notifies me about new e-mail even if the phone entered sleep mode.


[update]You can use a WifiLock to keep WiFi active, while holding the lock.

Using an AlarmManager and a Service says to me your service is running only for a very short time!? I think (though can't say for certain) that you should make your service a forground service (check the blog for a good way to implement this on both 1.x and 2.x+) and leave the AlarmManager out of it.

0

精彩评论

暂无评论...
验证码 换一张
取 消