当Android手机是睡着了网络访问 [英] Network access when the Android phone is asleep

查看:150
本文介绍了当Android手机是睡着了网络访问的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

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

唯一的问题我已经是当睡眠政策终止的Wi-Fi连接的同步不再工作。

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

有没有办法来唤醒的Wi-Fi连接已被置于睡觉? GMail的还是设法做到这一点,因为它会通知我关于新的电子邮件即使手机进入睡眠模式。

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.

推荐答案

[更新]您可以使用的 WifiLock 保持无线活跃,而持有该锁。

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

使用 AlarmManager 服务对我说:你的服务仅在很短的时间内运行!?我认为,(虽然不能肯定地说),你应该让你的服务forground服务(检查博客为实施这一两个1.x和2.x +的好办法),并离开 AlarmManager 出来。

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.

这篇关于当Android手机是睡着了网络访问的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆