Android连接指定WIFI

        WifiConfiguration config = new WifiConfiguration();
        config.SSID = "\"WIFI_NAME\"";
        config.preSharedKey = "\"PASSWORD\"";
        config.hiddenSSID = true;
        config.status = WifiConfiguration.Status.ENABLED;
        config.allowedGroupCiphers.set(WifiConfiguration.GroupCipher.TKIP);
        config.allowedGroupCiphers.set(WifiConfiguration.GroupCipher.CCMP);
        config.allowedPairwiseCiphers.set(WifiConfiguration.PairwiseCipher.TKIP);
        config.allowedPairwiseCiphers.set(WifiConfiguration.PairwiseCipher.CCMP);
        config.allowedKeyManagement.set(WifiConfiguration.KeyMgmt.WPA_PSK);
        config.allowedProtocols.set(WifiConfiguration.Protocol.WPA);  
        int netId = manager.addNetwork(config);
        boolean b = manager.enableNetwork(netId, true);

你可能感兴趣的:(android,wifi)