我们找到 android.net.wifi.WifiConfiguration.java 看看如何配置Wifi信息。

/**************************************SSID**********************/

/**

* The network's SSID. Can either be an ASCII string,

* which must be enclosed in double quotation marks

* (e.g., [email protected] "MyNetwork"}, or a string of

* hex digits,which are not enclosed in quotes

* (e.g., [email protected] 01a243f405}).

*/

public String SSID; //请看注释: 如果是 ASCII 码 SSID必须要 " " 包裹起来

/**************************************BSSID**********************/

/**

* When set, this network configuration entry should only be used when

* associating with the AP having the specified BSSID. The value is

* a string in the format of an Ethernet MAC address, e.g.,

* XX:XX:XX:XX:XX:XX where each X is a hex digit.

*/

public String BSSID; //但是我发现 在配置信息的时候,BSSID 是不能赋值的

/******************************************* preSharedKey*********************/

/**

* Pre-shared key for use with WPA-PSK.

*

* When the value of this key is read, the actual key is

* not returned, just a "*" if the key has a value, or the null

* string otherwise.

*/

public String preSharedKey; //这是WPA模式 加密的,密码赋值的地方

/*************************************wepKeys******************/

/**

* Up to four WEP keys. Either an ASCII string enclosed in double

* quotation marks (e.g., [email protected] "abcdef"} or a string

* of hex digits (e.g., [email protected] 0102030405}).

*

* When the value of one of these keys is read, the actual key is

* not returned, just a "*" if the key has a value, or the null

* string otherwise.

*/

public String[] wepKeys;// 这是WEP加密 密码赋值的地方,必须考虑ASCII

//***************基于属性太多 我只是把一些重要的属性列出来,其他属性 自己去看

下面开始配置wifi信息。

/**************************web 配置信息****************************/

config.SSID = """.concat(SSID).concat(""");

config.status = WifiConfiguration.Status.DISABLED;

config.priority = 40;

config.allowedKeyManagement.set(WifiConfiguration.KeyMgmt.NONE);

config.allowedProtocols.set(WifiConfiguration.Protocol.RSN);

config.allowedProtocols.set(WifiConfiguration.Protocol.WPA);

config.allowedAuthAlgorithms.set(WifiConfiguration.AuthAlgorithm.OPEN);

config.allowedAuthAlgorithms.set(WifiConfiguration.AuthAlgorithm.SHARED);

config.allowedPairwiseCiphers.set(WifiConfiguration.PairwiseCipher.CCMP);

config.allowedPairwiseCiphers.set(WifiConfiguration.PairwiseCipher.TKIP);

config.allowedGroupCiphers.set(WifiConfiguration.GroupCipher.WEP40);

config.allowedGroupCiphers.set(WifiConfiguration.GroupCipher.WEP104);

if (isHexWepKey(Password))

config.wepKeys[0] = Password;

else

config.wepKeys[0] = """.concat(Password).concat(""");

config.wepTxKeyIndex = 0;

/***************************wpa配置信息*****************************/

config.SSID = """ + SSID + """;

config.hiddenSSID = false;

config.status = WifiConfiguration.Status.ENABLED;

config.allowedAuthAlgorithms.set(WifiConfiguration.AuthAlgorithm.OPEN);

config.allowedProtocols.set(WifiConfiguration.Protocol.WPA);

config.allowedProtocols.set(WifiConfiguration.Protocol.RSN); // For WPA2

config.allowedKeyManagement.set(WifiConfiguration.KeyMgmt.WPA_PSK);

config.allowedKeyManagement.set(WifiConfiguration.KeyMgmt.WPA_EAP);

config.allowedPairwiseCiphers.set(WifiConfiguration.PairwiseCipher.TKIP);

config.allowedPairwiseCiphers.set(WifiConfiguration.PairwiseCipher.CCMP);

config.allowedGroupCiphers.set(WifiConfiguration.GroupCipher.CCMP);

config.allowedGroupCiphers.set(WifiConfiguration.GroupCipher.TKIP);

config.preSharedKey = """ + Password + """;

config.priority =1;

/****************************无密码的配置***********************/

config.wepKeys[0] = "";

config.allowedKeyManagement.set(WifiConfiguration.KeyMgmt.NONE);

config.wepTxKeyIndex = 0;

wifiManager.addNetwork(wifiConfig); //添加配置信息,返回NetworkId, 如果是-1 则配置失败

wifiManager.saveConfiguration();//保存信息

wifiManager.enableNetwork(NetWorkId,true);//连接返回的NetWordID,并且断开其他的Wifi连接。

android wifi动画显示,android动态配置Wifi信息相关推荐

  1. android wifi动画显示,Android获取WiFi列表的正确用法

    最近有个需求,需要做一个获取WiFi列表的功能,也在网上找了一些资料,但有些资料是有问题的,然后经过自己的摸索,总结如下: 本地环境: Android Studio版本:3.0.1:DEMO APK ...

  2. Android Gradle 多渠道打包、动态配置AppName

    目录 一.简介 二.Gradle多渠道打包 1.普通做法 2.Gradle多渠道打包 一.简介 因为国内Android应用分发市场的现状,我们在发布APP时,一般需要生成多个渠道包,上传到不同的应用市 ...

  3. android 硬币翻转动画,使用Android标准动画显示正在翻转的硬币的两面

    我非常接近制作"硬币翻转"动画,但是由于当前动画系统的局限性(错误?) – 我无法找到一种方法来显示硬币在空中翻转的两侧. 例如,我有以下动画.XML: android:share ...

  4. android 文字动画显示,用粒子动画显示各种文字的 Android 自定义 View

    一.总述 ParticleTextView 是一个 Android 平台的自定义 view 组件,可以用彩色粒子组成指定的文字,并配合多种动画效果和配置属性,呈现出丰富的视觉效果. 二.使用 1. 引 ...

  5. Android使用动画显示或隐藏视图

    一.需求背景 有时候,我们需要在屏幕上显示新的信息,同时移除旧的信息,一般情况下我们通过VISIBILITY或者GONE来对需要显示或者隐藏的视图进行设置,这样做的坏处是显示或者隐藏的动作变化非常突兀 ...

  6. android 文本分页显示,Android查看带有列表视图的分页器并动态添加文本

    我在一个分片活动中有一个Viewpager,它有一个带有编辑文本和发送按钮的botton框架. 在片段布局中,我有一个ListView,并在片段中附加了一个适配器.现在我正在实现从片段中的Parent ...

  7. Android三步显示gif动态图片

    1.把GifView.jar加入你的项目. 2.在布局xml中这样写: [html] view plaincopyprint? <com.ant.liao.GifView android:id= ...

  8. android解锁动画效果,Android 5秒学会使用手势解锁功能

    Android手势解锁 本文讲述的是一个手势解锁的库,可以定制显示隐藏宫格点.路径.并且带有小九宫格显示图,和震动!让你学会使用这个简单,高效的库! 先来一波效果效果展示: 手势解锁效果 今天给大家介 ...

  9. android矢量动画 充电,android矢量动画

    android矢量动画! 直接来个例子就明白了!(这里我把与动画无关的属性都用-表示) 首先你要有个矢量图 比如这个矢量图xml文件叫"vector1",文件在res\drawab ...

最新文章

  1. c语言编程员工管理的代码,员工信息管理完整(含附源代码).doc
  2. Python中import模块的两种模式
  3. linux cat 文本颜色,linux文本文件查看、展示命令 :cat head tail grep more less nl
  4. 怎么主动发起话题_为什么男生不愿意主动追求女生了?这或许是最终的核心原因...
  5. jeecg集成实现websocket
  6. 配色方案为您的下一个设计项目准备,照着配准没错!
  7. osip和mysql_osip2和eXosip2协议
  8. 人工智能语音电视能“听话”吗?
  9. 用python画一只皮卡丘_画皮卡丘怎么执行不了
  10. MYSQL的简单命令
  11. [Hadoop]Hive r0.9.0中文文档(二)之联表查询Join
  12. J2EE开发系列教程-J2EE视频教程 实例
  13. sun java认证真题,sun scjp考试心得_java认证
  14. 计算机常用的英语单词及缩写,常见计算机英语缩写及单词
  15. Acwing第741题(斐波那契数列)
  16. FCPX插件:镜头光晕眩光特效插件PHYX Flarelight
  17. Excel中多行一致分类序列号
  18. c++三大函数:拷贝构造(copy ctor)、拷贝赋值(copy op)、析构函数(dtor)
  19. C语言基础之3:数据与C
  20. c语言windows画五角星,C/C++画一个巨型五角星

热门文章

  1. Redis 哨兵架构基础
  2. 面试:说说啥是一致性哈希算法?
  3. 三款云数据库性能测试,谁表现最好?
  4. 大数据文字游戏_基于大数据的游戏化教学系统研究.docx
  5. oracle存储过程详解--游标 实现增、删、改、查的
  6. Python Numba CPU下加速
  7. Python xml ElementTree 缩进(autoindent) 换行
  8. Flask入门之Jinjia模板的一些语法
  9. JobScheduler的使用
  10. java自动生成数据库代码