Android学习笔记-Wifi网络操作
2016-02-04 11:06
281 查看
Wifi网卡状态
WIFI_STATE_DISABLED Wifi网卡不可用
WIFI_STATE_DIABLING Wifi网卡正在关闭
WIFI_STATE_ENABLED Wifi网卡可用
WIFI_STATE_ENABLING Wifi网卡正在打开
WIFI_STATE_UNKNOWN 未知网卡状态
操作Wifi网卡所需要的权限
CHANGE_NETWORK_STATE 改变网络连接状态
CHANGE_WIFI_STATE 改变Wifi连接状态
ACCESS_NETWORK_STATE 允许应用获取网络状态信息
ACCESS_WIFI_STATE 允许应用获取Wifi状态信息
界面activity_main.xml
[code=xml;toolbar:false"> <TextView
android:id="@+id/hello"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/hello_world" />
<Button
android:id="@+id/startWifi"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="@id/hello"
android:text="启动手机的wifi网卡"
/>
<Button
android:id="@+id/stopWifi"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="@id/startWifi"
android:text="关闭手机的wifi网卡"
/>
<Button
android:id="@+id/checkWifi"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="@id/stopWifi"
android:text="检查当前wifi网卡状态"
/>
WIFI_STATE_DISABLED Wifi网卡不可用
WIFI_STATE_DIABLING Wifi网卡正在关闭
WIFI_STATE_ENABLED Wifi网卡可用
WIFI_STATE_ENABLING Wifi网卡正在打开
WIFI_STATE_UNKNOWN 未知网卡状态
操作Wifi网卡所需要的权限
CHANGE_NETWORK_STATE 改变网络连接状态
CHANGE_WIFI_STATE 改变Wifi连接状态
ACCESS_NETWORK_STATE 允许应用获取网络状态信息
ACCESS_WIFI_STATE 允许应用获取Wifi状态信息
界面activity_main.xml
[code=xml;toolbar:false"> <TextView
android:id="@+id/hello"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/hello_world" />
<Button
android:id="@+id/startWifi"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="@id/hello"
android:text="启动手机的wifi网卡"
/>
<Button
android:id="@+id/stopWifi"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="@id/startWifi"
android:text="关闭手机的wifi网卡"
/>
<Button
android:id="@+id/checkWifi"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="@id/stopWifi"
android:text="检查当前wifi网卡状态"
/>
相关文章推荐
- Android学习笔记-网络编程
- WebService学习笔记-XML&Schema&HTTP
- servlet学习六--HttpServletRequest对象学习
- servlet学习四--HttpServletResponse对象学习二
- servlet学习三--HttpServletResponse对象学习
- CORS 跨域 node |XMLHttpRequest 跨域提交数据 node
- Qt之进程间通信(TCP/IP)
- Qt之进程间通信(TCP/IP)
- Android 网络请求Volley库完全解析,Volley的基本用法(二)
- 使用 obfsproxy 混淆网络流量
- 知名网络后端开源软件集合
- TCP服务器端和客户端程序设计
- HttpMessageNotWritableException: Could not write JSON: No serializer found for class ****
- https 后面补充session
- 2016SEM百度竞价如何分词【太原网络营销师】{郭文军}解析
- 厦门巨游网络科技有限公司(HOTPOWER)承接游戏UI外包
- #TCP你学得会# 之 当listen和accept遇到fork
- 网络工程 POST与GET请求方法的本质区别
- 基于TCP流协议的数据包通讯
- TCP与IP协议的相互作用