마스터Q&A 안드로이드는 안드로이드 개발자들의 질문과 답변을 위한 지식 커뮤니티 사이트입니다. 안드로이드펍에서 운영하고 있습니다. [사용법, 운영진]

Wifi 접속시 고정IP로 접속을 하고싶은데요.

0 추천
Wifi 접속시 고정IP로 접속을 하고싶은데요.

도저히 못찾겠습니다.

뭐가 잘못된건지 알려주시면 감사하겠습니다.

 

final ContentResolver cr = getContentResolver();        
        Settings.System.putInt(cr, Settings.System.WIFI_USE_STATIC_IP, 0);
        Settings.System.putString(cr, Settings.System.WIFI_STATIC_IP, "192.161.11.111");
        Settings.System.putString(cr, Settings.System.WIFI_STATIC_NETMASK, "255.255.255.0");
        Settings.System.putString(cr, Settings.System.WIFI_STATIC_GATEWAY, "192.161.11.254");
        Settings.System.putString(cr, Settings.System.WIFI_STATIC_DNS1, "0.0.0.0");
        Settings.System.putString(cr, Settings.System.WIFI_STATIC_DNS2, "0.0.0.0");
        Settings.System.putInt(cr, Settings.System.WIFI_USE_STATIC_IP, 1);
        
        WifiConfiguration wfc = new WifiConfiguration();
        wfc = new WifiConfiguration();  
        wfc.SSID = "\"".concat("APSSID").concat("\"");
        wfc.status = WifiConfiguration.Status.DISABLED;
        wfc.priority = 40;
        
        
        wfc.allowedAuthAlgorithms.set(WifiConfiguration.AuthAlgorithm.OPEN);
        wfc.allowedProtocols.set(WifiConfiguration.Protocol.RSN);
        wfc.allowedKeyManagement.set(WifiConfiguration.KeyMgmt.WPA_PSK);
        wfc.allowedPairwiseCiphers.set(WifiConfiguration.PairwiseCipher.CCMP);
        wfc.allowedPairwiseCiphers.set(WifiConfiguration.PairwiseCipher.TKIP);
        wfc.allowedGroupCiphers.set(WifiConfiguration.GroupCipher.CCMP);
        wfc.allowedGroupCiphers.set(WifiConfiguration.GroupCipher.TKIP);
        wfc.preSharedKey = "\"".concat("APPW").concat("\"");
        
        
        
        WifiManager wfMgr = (WifiManager) getSystemService(Context.WIFI_SERVICE);
        
        int networkId = wfMgr.addNetwork(wfc);
        wfMgr.saveConfiguration();
        if (networkId != -1) {
            boolean ok = wfMgr.enableNetwork(networkId, true);
        }
철웅 (120 포인트) 님이 2016년 1월 11일 질문

답변 달기

· 글에 소스 코드 보기 좋게 넣는 법
· 질문에 대해 추가적인 질문이나 의견이 있으면 답변이 아니라 댓글로 달아주시기 바랍니다.
표시할 이름 (옵션):
개인정보: 당신의 이메일은 이 알림을 보내는데만 사용됩니다.
스팸 차단 검사:
스팸 검사를 다시 받지 않으려면 로그인하거나 혹은 가입 하세요.
...