WifiManager.getScanResults() - 澄清(自动扫描,睡眠等) [英] WifiManager.getScanResults() - clarifications (automatic scans, sleep etc)
问题描述
我想一些澄清的行为 WifiManager.getScanResults()
,即:
I would like some clarifications on the behavior of WifiManager.getScanResults()
, namely :
当无线启用的
- 是否在一个固定的时间间隔接入点的android扫描?可以在一个查询/修改时间?一个人能查询上次扫描的时间呢?对于讨论,请参阅此回答
- 当无线电关闭时会发生什么情况(休眠) - 无线上网的同时仍启用 - 将
getScanResults()
走在返回的最后一次扫描的结果?一个人怎么会知道,如果它的时间为startScan()
?
- Does android scan for access points on a fixed interval ? Can one query/change the interval ? Can one query the time of the last scan ? For a discussion see this answer
- What happens when the wireless radio is turned off (sleeps) - while wifi is still enabled - will
getScanResults()
go on returning the last scan results ? How would one know if it's time forstartScan()
?
无线时禁用的
-
getScanResults()
将返回上次扫描结果?一个空列表?或空
(它有时返回null,这不是90%张贴在这样的片段的处理)? - 答案1甚至会重新启动(手机启动与WiFi关闭)? 在真
getScanResults()
would return the last scan results ? Or an empty List ? Ornull
(it does return null at times and this is not handled by 90% of the snippets posted in SO) ?- The answer to 1 would be true even after a reboot (the phone booting with wifi off) ?
我想问的原因是我需要定期获得的可用接入点列表,我宁愿放弃 getScanResults()
一次,比 WifiManager.startScan()
然后 getScanResults()
如果我真的没有 - 因为这涉及到收购的WiFi锁等,并是相当微妙的。我不是也知道有多少千万的API级别和手机硬件发挥作用。
The reason I ask is I need to get the list of the available access points periodically and I'd rather call getScanResults()
at once, than WifiManager.startScan()
and then getScanResults()
if I really do not have to - as this involves acquiring wifi locks and the like and is rather subtle. I am not also sure how much do the API level and phone hardware come into play.
有关困难了良好的讨论,请参阅该<一href="http://stackoverflow.com/questions/14862018/startscan-has-result-after-10-min-when-phone-get-into-idle-state/14910918#14910918">answer
For a good discussion of difficulties see this answer
推荐答案
无线时禁用的
-
getScanResults()
返回空
... - ...即使重新启动(这是可以预料的 - 这将是有争议的,如果它没有在第一时间返回null)
getScanResults()
will returnnull
...- ...even after a reboot (that's to be expected - this would be disputed if it did not return null in the first place)
编辑:当无线启用的
2.Surprisingly足够 getScanResults()
返回空
一段时间后(在Nexus One的,安卓2.3 .7氰MOD - 但我怀疑这是不是真的有关)。所以,是的,显然一个人无论以启动无线状态的扫描
2.Surprisingly enough getScanResults()
will return null
after some time (on a Nexus One, Android 2.3.7, Cyanogen mod - but I suspect this is not really relevant). So yes, apparently one has to initiate a scan irrespective of the wireless status
我想这是事实也是如果状态 WIFI_STATE_DISABLING
I guess this is true also if the state is WIFI_STATE_DISABLING
我仍然有兴趣在无线的情况下,答案已启用 - 尤其是第2个问题,如果该设备是睡着了。谷歌集团不会让我上传(提示)
I am still interested in the answer in the case wireless is enabled - in particular question 2, if the device is asleep. Google groups won't let me post (hint)
这篇关于WifiManager.getScanResults() - 澄清(自动扫描,睡眠等)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!