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可用时做一些操作,这个很有用。

更多相关文章

  1. Android程序开发调试工具(一):dx和dexdump
  2. Android系统应用程序安装过程源码分析
  3. android 开发 调用第三方程序
  4. Android获取状态栏、标题栏、ActionBar以及屏幕的高度
  5. Android状态栏上添加按钮
  6. Android应用程序键盘(Keyboard)消息处理机制分析(5)
  7. [转]android两次按返回键退出程序实现
  8. android去掉layout顶部的阴影(状态栏下边的阴影)
  9. Android 状态栏和应用标题栏颜色保持一致

随机推荐

  1. Android(安卓)实时获取麦克风输入音量的
  2. 阿里Android开发规范:UI 与布局
  3. 换个角度理解Android的AIDL原理
  4. 毕加索的艺术——Picasso,一个强大的Andr
  5. Android护眼模式、屏幕亮度调节功能开发
  6. Android 4.0按键事件以及电源管理流程分
  7. 深入分析android中用SAX解析XML文件并纠
  8. Android的WebView控件载入网页显示速度慢
  9. Android实现系统级屏幕录制(上)
  10. Android的IPC机制(五)—— ContentProvider