【问题标题】:How to create a Android WifiConfiguration and access wifi with username/password如何创建 Android WifiConfiguration 并使用用户名/密码访问 wifi
【发布时间】:2011-03-09 12:34:33
【问题描述】:

WifiConfiguration conf = new WifiConfiguration(); conf.SSID = "ssid"; conf.preSharedKey = "\"密码\""; conf.status = WifiConfiguration.Status.ENABLED;

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

conf.allowedGroupCiphers.set(WifiConfiguration.GroupCipher.WEP40); 
conf.allowedGroupCiphers.set(WifiConfiguration.GroupCipher.WEP104);
conf.allowedGroupCiphers.set(WifiConfiguration.GroupCipher.TKIP);
conf.allowedGroupCiphers.set(WifiConfiguration.GroupCipher.CCMP);

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

conf.allowedPairwiseCiphers.set(WifiConfiguration.PairwiseCipher.TKIP);
conf.allowedPairwiseCiphers.set(WifiConfiguration.PairwiseCipher.CCMP);

conf.allowedProtocols.set(WifiConfiguration.Protocol.WPA);
conf.allowedProtocols.set(WifiConfiguration.Protocol.RSN);

int res = wifi.addNetwork(conf);
boolean b = wifi.enableNetwork(res, true);

此 wifi 接入点需要用户名 + 密码才能连接,但我找不到任何设置密码的方法。我认为这是我无法成功创建的问题。

请帮助我。非常感谢。

【问题讨论】:

    标签: android configuration wifi account


    【解决方案1】:

    你已经设置了WifiConfiguration.wepKeys

    conf.wepKeys[0] = "\"password\"";
    

    here 是一个非常好的例子。

    【讨论】:

      猜你喜欢
      • 2013-11-22
      • 2019-12-25
      • 2018-10-11
      • 2019-01-30
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-08-09
      • 1970-01-01
      相关资源
      最近更新 更多