1. 检测是否有wifi可用:
mWifiManager = (WifiManager) context.getSystemService(Context.WIFI_SERVICE);
if (mWifiManager != null) {
List<ScanResult> wifiScanResults = mWifiManager.getScanResults();
if (wifiScanResults != null && wifiScanResults.size() != 0) {
}
}
2. WifiLock的应用:
这儿有一篇详细的文章介绍http://malaqu.com/?p=1203
WifiLock Allows an application to keep the Wi-Fi radio awake. Normally
the Wi-Fi radio may turn off when the user has not used the device in a
while. Acquiring a WifiLock will keep the radio on until the lock is
released. Multiple applications may hold WifiLocks, and the radio will
only be allowed to turn off when no WifiLocks are held in any
application.
Before using a WifiLock, consider carefully if your application
requires Wi-Fi access, or could function over a mobile network, if
available. A program that needs to download large files should hold a
WifiLock to ensure that the download will complete, but a program whose
network usage is occasional or low-bandwidth should not hold a WifiLock
to avoid adversely affecting battery life.
Note that WifiLocks cannot override the user-level “Wi-Fi Enabled”
setting, nor Airplane Mode. They simply keep the radio from turning off
when Wi-Fi is already on but the device is idle.
3. 在程序中注册WifiManager.SCAN_RESULTS_AVAILABLE_ACTION和WifiManager.WIFI_STATE_CHANGED_ACTION这两个intent,以关注Wifi的状态,要是程序有需求在wifi可用时做一些操作,这个很有用。
分享到:
相关推荐
并敌一向——读孙子兵法有感1000字-读书笔记.docx
并敌一向——读孙子兵法有感1000字.docx
小议中华文化之精髓与糟粕——读《三字经》有感.docx
学习的力量——读《为中华之崛起而读书》有感.pdf
双城的创伤——读《看见》有感1000字-读书笔记.docx
小议中华文化之精髓与糟粕——读《三字经》有感_1.docx
读书心得——读《淡定的人生不寂寞》有感参考.doc
医疗与社会——读《英格兰的疾病、医学与社会,1550—1860》有感.pdf
大雪压青松青松挺且直——读陈毅同志诗词有感.pdf
命运与抗争——读《穆斯林的葬礼》有感(1000字).docx.docx
战争审视下的忠与义——读《菊与刀》有感-(2000字).docx.docx
《读书伴我成长——读小白兔与小灰兔故事有感》这篇文档,虽然标签为“事业编”,但其实它更侧重于个人成长与教育的重要性。故事通过对比小白兔和小灰兔的行为习惯,生动地阐述了良好的学习态度和自律对于个人成就的...
——读《跨世纪经理人怎样提升自己的素质与能力》有感_1.docx
小学古诗词分层式教学与建构主义——读《语文课程改革研究》有感.doc
关于爱的作文600字爱与希望——读《草原上的小木屋》有感.doc
办法总比困难多——读《网络安全和信息化》有感.pdf
多想一步——读《世界地图引出的发现》有感.docx
动物革命——读《动物农场》有感(1500字).docx.docx
苦难的一生——读《骆驼祥子》有感(1000字).docx.docx
消逝与重生——读《杀死一只知更鸟》有感(1500字).docx.docx