이 코드를 Android <5.0에서 문제없이 사용했습니다.
// //////////// save network
WifiConfiguration wc = new WifiConfiguration();
ConfigurationSecuritiesV8 conf = new ConfigurationSecuritiesV8();
conf.setupSecurity(wc, conf.getScanResultSecurity(scanResult), password);
wc.BSSID = scanResult.BSSID;
wc.SSID = "\"" + scanResult.SSID.replace("\"", "") + "\"";
int id = wifiManager.addNetwork(wc);
if (id == -1)
return RESULT_CANT_CREATE_NETWORK;
Nexus 5에 새로운 Android 5.0을 설치하기 만하면 이제 프로그래밍 방식으로 네트워크를 추가 할 수 없습니다.
나는 문제를 좋아한다. 나는 내 코드를 다음과 같이 변경해야한다.
if (Build.VERSION.SDK_INT >= 21)
wc.SSID = "" + scanResult.SSID.replace("\"", "") + "";
else
wc.SSID = "\"" + scanResult.SSID.replace("\"", "") + "\"";
이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.
침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제
몇 마디 만하겠습니다