0
我怎麼可以用WPS協議編程連接到wifi? 我發現如何連接WEP,WPA和開放的WiFi,但不是WPS ...以編程方式在Android中建立WPS連接?
謝謝大家!
編輯時,Greg432
我試試這個代碼,但它不工作,解決的答案?
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
wpsInfo = new WpsInfo();
wpsInfo.BSSID = wifiList.get(0).BSSID;
wpsInfo.pin = "11883737";
wpsInfo.setup = 0;
wpsCallback = new WifiManager.WpsCallback() {
@Override
public void onStarted(String pin) {
Toast.makeText(getApplicationContext(), "Started wps connection.", Toast.LENGTH_SHORT).show();
}
@Override
public void onSucceeded() {
Toast.makeText(getApplicationContext(), "Connected!", Toast.LENGTH_SHORT).show();
}
@Override
public void onFailed(int reason) {
String errorMessage;
switch (reason) {
case WifiManager.WPS_OVERLAP_ERROR:
errorMessage = "WPS_OVERLAP_ERROR";
break;
case WifiManager.WPS_WEP_PROHIBITED:
errorMessage = "WPS_WEP_PROHIBITED";
break;
case WifiManager.WPS_TKIP_ONLY_PROHIBITED:
errorMessage = "WPS_WEP_PROHIBITED";
break;
/*case WifiManager.IN_PROGRESS:
mWifiManager.cancelWps(null);
startWps();
return;*/
case WifiManager.WPS_TIMED_OUT:
errorMessage = "WPS_TIMED_OUT";
//startWps();
return;
default:
errorMessage = "Generic error.";
break;
}
Toast.makeText(getApplicationContext(), errorMessage, Toast.LENGTH_SHORT).show();
}
};
wifiManager.startWps(wpsInfo, wpsCallback);
}
嗨!謝謝你的回答,我試圖寫一個代碼,但不能很好地工作......你能看嗎? –