Android - 如何唤醒wifi?
我有一个应用程序每 5 分钟发送一次数据,我看到 wifi 一段时间后进入睡眠状态并停止工作。
我找到了一种使用 WakeLock SCREEN_DIM_WAKE_LOCK
的解决方案。 问题是:在此过程中我无法唤醒屏幕(甚至变暗)。 PARTIAL_WAKE_LOCK
在这种情况下不起作用(唤醒 wifi)。
这个问题还有另一种解决方案吗?
更新:
我正在使用此主题方法来锁定 wifi,但也不起作用: Wifi 睡眠,即使有锁定
有什么问题吗?
I have an app that sends data every 5 min, i saw that wifi after some time goes sleep and stop working.
I found one solution that is use a WakeLock SCREEN_DIM_WAKE_LOCK
.
The thing is: i can't have my screen waking (even dimmed) in this process. PARTIAL_WAKE_LOCK
doesn't work in this case (to wake up wifi).
There is another solution for this problem?
UPDATE:
I'm using this topic method to lock wifi, and isn't work either:
Wifi sleeps, even with Lock
There is something wrong?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您是否尝试过使用
WifiManager.WifiLock
?创建并持有 wifiLock 是让您的无线电保持足够清醒以进行发送的方式。另请检查:在发送消息之前,打印出 ConnectivityManager 对您的 TYPE_WIFI 连接的看法。 ConnectivityManager 认为您的 wifi 一切正常吗?
Have you tried using
WifiManager.WifiLock
? Creating and holding a wifiLock is the way your suppose to keep your radio awake enough to send.Also check: Just prior to sending your message, print out what ConnectivityManager thinks about your TYPE_WIFI connection. Does the ConnectivityManager think all is well with your wifi?