Android手机休眠时网络访问

发布于 2024-08-26 17:21:58 字数 196 浏览 2 评论 0原文

我使用警报(使用 AlarmManager 设置)和后台服务的组合来定期同步应用程序中的数据。

我遇到的唯一问题是,当睡眠策略终止 Wi-Fi 连接时,同步将不再起作用。

有没有办法“唤醒”已进入睡眠状态的 Wi-Fi 连接? GMail 以某种方式设法做到了这一点,因为即使手机进入睡眠模式,它也会通知我有新电子邮件。

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 connection 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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

断舍离 2024-09-02 17:21:58

[更新]您可以使用 WifiLock 保持 WiFi 活动,同时保持锁定。

使用 AlarmManagerService 对我来说,你的服务只运行了很短的时间!?我认为(尽管不能肯定地说)您应该将您的服务设为前台服务(查看博客以了解在 1.x 和 2.x+ 上实现此功能的好方法)并保留 AlarmManager出来了。

[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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文