良い質問。定義された AP に接続してみて、結果を確認してください。
WifiConfiguration wc = new WifiConfiguration();
...
// If password is empty, it should be left untouched
if (!TextUtils.isEmpty(pswd)) {
if (pswd.length() == 64) {
// Goes unquoted as hex
wc.preSharedKey = pswd;
} else {
// Goes quoted as ASCII
wc.preSharedKey = TextUtil.convertToQuotedString(pswd);
}
}
int res = -1;
res = m_WifiManager.addNetwork(wc);
boolean b = m_WifiManager.enableNetwork(res, true);
if(b == true){
fixSupplicant();
m_WifiManager.saveConfiguration();
//success
}
else{
//failed
....
private void fixSupplicant() {
final SupplicantState state = m_WifiManager.getConnectionInfo().getSupplicantState();
boolean isReconnectDone = false;
if ((state == SupplicantState.SCANNING)
|| (state == SupplicantState.DISCONNECTED)
|| (state == SupplicantState.DORMANT)) {
isReconnectDone = m_WifiManager.reconnect();;
}
}