Android:用contains提取wifi功能
作者:互联网
我想知道扫描网络的类型安全性,我得到的结果如下:
[WPA-PSK-TKIP+CCMP][WPA2-PSK-TKIP+CCMP][ESS]
[WPA2-PSK-CCMP][WPS][ESS]
我用这个代码:
// Constants used for different security types
public static final String WPA = "WPA";
public static final String WEP = "WEP";
public static final String WPA2 = "WPA2";
public static final String OPEN = "Open";
final String cap = results.get(position).capabilities;
final String[] securityModes = { WEP, WPA, WPA2 };
for (int i = securityModes.length - 1; i >= 0; i--) {
if (cap.toLowerCase().contains(securityModes[i].toLowerCase())) {
textView5.setText(securityModes[i] );
}
else
textView5.setText(OPEN );
}
但我只是在textViex中获取:OPEN或WEP,我没有得到WPA或WPA2,可能是什么问题?
解决方法:
试试这个功能:
public String security(String cap){
if (cap.toLowerCase().contains(WEP.toLowerCase()))
{return WEP ;}
else if (cap.toLowerCase().contains(WPA2.toLowerCase()))
{return WPA2;}
else if (cap.toLowerCase().contains(WPA.toLowerCase()))
{return WPA;}
else
return OPEN;
}
标签:android,contains,wifi,wpa,wep 来源: https://codeday.me/bug/20191001/1839677.html