Android examples for Phone:wifi
connect Wifi Ap
//package com.java2s; import android.net.wifi.WifiConfiguration; import android.net.wifi.WifiManager; public class Main { public static boolean connect2WifiAp(WifiManager wifiManager, String ssid, String bssid) { WifiConfiguration apConfig = new WifiConfiguration(); apConfig.BSSID = bssid;// w ww . j a v a 2 s. c om apConfig.SSID = "\"" + ssid + "\""; apConfig.hiddenSSID = true; apConfig.status = WifiConfiguration.Status.ENABLED; apConfig.allowedGroupCiphers .set(WifiConfiguration.GroupCipher.TKIP); apConfig.allowedGroupCiphers .set(WifiConfiguration.GroupCipher.CCMP); apConfig.allowedKeyManagement.set(WifiConfiguration.KeyMgmt.NONE); apConfig.allowedPairwiseCiphers .set(WifiConfiguration.PairwiseCipher.TKIP); apConfig.allowedPairwiseCiphers .set(WifiConfiguration.PairwiseCipher.CCMP); apConfig.allowedProtocols.set(WifiConfiguration.Protocol.RSN); int wcgID = wifiManager.addNetwork(apConfig); boolean flag = wifiManager.enableNetwork(wcgID, true); return wifiManager.reconnect(); } }