私は Android が初めてです。私がしたいのは、利用可能なネットワークを検索してから、特定のネットワークをクリックすると、任意の Android デバイスにあるパスワードを入力するためのカスタム ダイアログ ボックスが表示されることです。問題は、次のコードの実行時に Wifi が記憶されてから無効になり、接続されないことです。以下は、目的のセキュリティで保護されたネットワークをクリックすると実行される私のコードです。Plsはこれで私を助けます
password = text.getText().toString().trim();
if(!password.equals(""))
{
wc.SSID = "\""+signal+"\""; //IMP! This should be in Quotes!!
wc.hiddenSSID = true;
System.out
.println("Oon click to action"+wc.SSID);
wc.status = WifiConfiguration.Status.ENABLED;
wc.priority = 40;
wc.allowedKeyManagement.set(WifiConfiguration.KeyMgmt.NONE);
wc.allowedProtocols.set(WifiConfiguration.Protocol.RSN);
wc.allowedProtocols.set(WifiConfiguration.Protocol.WPA);
wc.allowedAuthAlgorithms.set(WifiConfiguration.AuthAlgorithm.OPEN);
wc.allowedAuthAlgorithms.set(WifiConfiguration.AuthAlgorithm.SHARED);
wc.allowedPairwiseCiphers.set(WifiConfiguration.PairwiseCipher.CCMP);
wc.allowedPairwiseCiphers.set(WifiConfiguration.PairwiseCipher.TKIP);
wc.allowedGroupCiphers.set(WifiConfiguration.GroupCipher.WEP40);
wc.allowedGroupCiphers.set(WifiConfiguration.GroupCipher.WEP104);
wc.preSharedKey = "\"password\"";
// wc.wepKeys[0] = "\"password\""; //This is the WEP Password
wc.wepTxKeyIndex = 0;
int res = wifi.addNetwork(wc);
Log.d("WifiPreference", "add Network returned " + res );
boolean es = wifi.saveConfiguration();
Log.d("WifiPreference", "saveConfiguration returned " + es );
wifi.disconnect();
boolean b = wifi.enableNetwork(res, false);
wifi.reconnect();