简体   繁体   中英

How we can connect the wifi scan results to specific ssid network and want to launch app?

I have implemented code to get the wifi scan results & and tried to connect to particular specific networks which have good signal strength and after launching the app not able to open it.

Ref link:

WiFiActivity

Please provide your suggestions, any clue or lead would be a great help. Thanks in advance.

Try this code, hope it'll work

WifiConfiguration wifiConfig = new WifiConfiguration();
wifiConfig.SSID = String.format("\"%s\"", ssid);
wifiConfig.preSharedKey = String.format("\"%s\"", key);

WifiManager wifiManager = (WifiManager)getSystemService(WIFI_SERVICE);
//remember id
int netId = wifiManager.addNetwork(wifiConfig);
wifiManager.disconnect();
wifiManager.enableNetwork(netId, true);
wifiManager.reconnect();

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM