为您在睡眠模式下的WiFi网络信号 [英] Check for wifi networks signal in sleep mode

查看:205
本文介绍了为您在睡眠模式下的WiFi网络信号的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的目标是能够扫描Wi-Fi网络的变化(主要是检查哪些网络可用)。知道对不对,我注册一个reciever这样做:

My objective is to be able to scan changes in Wi-Fi networks (mainly to check what networks are available). Right know I'm doing it by registering a reciever:

registerReceiver(wifiReceiver, new IntentFilter(WifiManager.RSSI_CHANGED_ACTION));

其中, WifiReceiver 是我的广播接收器

问题是,它的工作原理,只有当手机处于开机状态。一旦它进入睡眠模式(通过按下电源按钮,或一段时间后),接收器停止接收。我已经收购了我的主类的onCreate唤醒锁和释放的onDestroy(它是一个局部唤醒锁)。此外,我已经试过这样:

The problem is that it works only when the phone is on. As soon as it goes to sleep mode (either by pushing the power button or after some time), the receiver stops receiving. I already acquired a wake lock in onCreate of my main class and releasing it in onDestroy (it's a partial wake lock). Additionally I've tried this:

Settings.System.putInt(getContentResolver(),Settings.System.WIFI_SLEEP_POLICY, Settings.System.WIFI_SLEEP_POLICY_NEVER);

要保持的WiFi睡觉。不幸的是没有帮助。

to keep wifi from sleeping. Unfortunately that didn't help.

是否有可能来扫描网络的变化,即使手机是睡着了吗?我希望能够检查什么网络是在范围(SSID)。也许我应该用另一种作用?

Is there any possibility to scan for network changes, even when phone is asleep? I want to be able to check what networks are in range (by SSID). Maybe I should use another action?

鸭preciate你的帮助。

Appreciate your help.

推荐答案

从字面上看,没有,硬件通常不会设计,也没有底层驱动程序写入允许无线操作,而应用CPU处于睡眠模式 - 不像例,其目的是接收推送事件,如电话,短信和Gmail发痒移动网络接口。

Literally, no, the hardware isn't typically designed nor the low level drivers written to allow wifi to operate while the application CPU is in sleep mode - unlike the case with the mobile network interface which is intended to receive push events like phone calls, sms, and gmail "tickles".

所以,你的选择是要么设法成功prevent睡觉设备(再见电池)或唤醒定期使用报警,打完了WiFi活跃,轮询情况(仍电池寿命并不好,但不是大幅的话)。

So your choices are to either manage to successfully prevent the device from sleeping (good bye battery) or wake up periodically using an alarm, kick the wifi active, and poll the situation (still not good for battery life, but not as drastically so).

这篇关于为您在睡眠模式下的WiFi网络信号的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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