博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
HTC 通过 WifiConfiguration 修改 SSID
阅读量:5970 次
发布时间:2019-06-19

本文共 7473 字,大约阅读时间需要 24 分钟。

http://www.dewen.org/q/5419 public void setHTCSSID(WifiConfiguration config, String ssid){        Field localField1;        try {            localField1 = WifiConfiguration.class.getDeclaredField("mWifiApProfile");            localField1.setAccessible(true);            Object localObject2 = localField1.get(config);            localField1.setAccessible(false);                       if(localObject2!=null){                Field localField5 = localObject2.getClass().getDeclaredField("SSID");                localField5.setAccessible(true);                localField5.set(localObject2, ssid);                localField5.setAccessible(false);                           }        } catch(Exception e) {            e.printStackTrace();        }    }

http://blog.sina.com.cn/s/blog_53dd443a010109i8.html

mnetConfig = new Wificonfiguration();….Field localField1;                try {                    localField1 = WifiConfiguration.class.getDeclaredField("mWifiApProfile");                    localField1.setAccessible(true);                    Object localObject2 = localField1.get(mnetConfig);                    localField1.setAccessible(false);                                       if(localObject2!=null){                        Field localField5 = localObject2.getClass().getDeclaredField("SSID");                        localField5.setAccessible(true);                        localField5.set(localObject2, netConfig.SSID);                        localField5.setAccessible(false);                                               Field localField4 = localObject2.getClass().getDeclaredField("BSSID");                        localField4.setAccessible(true);                        localField4.set(localObject2, netConfig.BSSID);                        localField4.setAccessible(false);                    }                } catch(Exception e) {                    e.printStackTrace();                }

  HTC Android Hotspot 热点配置 之DHCP

 

最近在研究手机热点的建立。HTC手机比较坑爹,首先一个,是不能按常规的办法修改 SSID, BSSID,

在网上搜了下,有篇博客把这个问题解决了,请参考:http://blog.sina.com.cn/s/blog_adc221ac01011mrs.html

 

private boolean setWifiSSIDForHTC(WifiConfiguration apConfig) {        boolean successed = true;        //        WifiConfiguration mnetConfig = new WifiConfiguration();        Field localField1;                        try {                            localField1 = WifiConfiguration.class.getDeclaredField("mWifiApProfile");                            localField1.setAccessible(true);                            Object localObject2 = localField1.get(apConfig);                            localField1.setAccessible(false);                            if(localObject2!=null){                                Field localField5 = localObject2.getClass().getDeclaredField("SSID");                                localField5.setAccessible(true);                                localField5.set(localObject2, apConfig.SSID);// netConfig.SSID);                                localField5.setAccessible(false);                                Field localField4 = localObject2.getClass().getDeclaredField("BSSID");                                localField4.setAccessible(true);                                localField4.set(localObject2, apConfig.BSSID);//netConfig.BSSID);                                localField4.setAccessible(false);                                                                Field localField6 = localObject2.getClass().getDeclaredField("dhcpEnable");                                localField6.setAccessible(true);//                                localField6.set(localObject2, "true");//netConfig.BSSID);                                localField6.setInt(localObject2, 1);                                localField6.setAccessible(false);                            }                        } catch(Exception e) {                            e.printStackTrace();                        }        return successed;    }

 

 

// 解决HTC热点设置问题                try {                        Field localField1 = WifiConfiguration.class                                        .getDeclaredField("mWifiApProfile");                        localField1.setAccessible(true);                        Object localObject2 = localField1.get(config);                        localField1.setAccessible(false);                        if (localObject2 != null) {                                // SSID设置                                Field localField5 = localObject2.getClass().getDeclaredField(                                                "SSID");                                localField5.setAccessible(true);                                localField5.set(localObject2, config.SSID);                                localField5.setAccessible(false);                                // IP地址设置                                Field localField4 = localObject2.getClass().getDeclaredField(                                                "ipAddress");                                localField4.setAccessible(true);                                localField4.set(localObject2, "192.168.1.1");                                localField4.setAccessible(false);                                // 子网掩码设置                                Field localField6 = localObject2.getClass().getDeclaredField(                                                "dhcpSubnetMask");                                localField6.setAccessible(true);                                localField6.set(localObject2, "255.255.255.0");                                localField6.setAccessible(false);                                // 安全类型设置                                Field localField2 = localObject2.getClass().getDeclaredField(                                                "secureType");                                localField2.setAccessible(true);                                if (appwd.equals("")) {                                        localField2.set(localObject2, "open");                                } else {                                        localField2.set(localObject2, "wpa2-psk");                                }                                localField2.setAccessible(false);                                // 密码设置                                Field localField3 = localObject2.getClass().getDeclaredField(                                                "key");                                localField3.setAccessible(true);                                localField3.set(localObject2, config.preSharedKey);                                localField3.setAccessible(false);                                // 起始IP设置                                Field localField8 = localObject2.getClass().getDeclaredField(                                                "startingIP");                                localField8.setAccessible(true);                                localField8.set(localObject2, "192.168.1.100");                                localField8.setAccessible(false);                                // DHCP设置                                Field localField7 = localObject2.getClass().getDeclaredField(                                                "dhcpEnable");                                localField7.setAccessible(true);                                localField7.set(localObject2, 1);                                localField7.setAccessible(false);                        }                } catch (Exception e) {                        System.out.println(e);                }                // HTC热点设置完毕

 

转载地址:http://qkwox.baihongyu.com/

你可能感兴趣的文章
MongoDB的安装和使用
查看>>
fix不抖动ie6
查看>>
SVN提交代码时全选文件
查看>>
Frament填坑
查看>>
使用spark-sql-perf评测spark 2.0
查看>>
Android下 scrollview的滚动停止事件的监听方法
查看>>
数据结构与算法之KMP算法02
查看>>
×××安全协议之IPsec
查看>>
用Unity3D的50个技巧:Unity3D最佳实践
查看>>
记录:C#编程中的字符串
查看>>
NEO从源码分析看NEOVM
查看>>
我的友情链接
查看>>
Btrfs入门(一)
查看>>
java中的匿名内部类总结
查看>>
多线程(一、线程安全案例)
查看>>
mysql之DDL操作--数据库
查看>>
java json格式的转换和读取
查看>>
find的命令的使用和文件名的后缀
查看>>
恢复WORD2010的默认模板2011-05-03
查看>>
Test2 unit2
查看>>