WifiManager.enableNetwork Fails to connect
I am facing a problem in connecting to a specific network(say A), through code.
My code snippet is :
tmpConfig = new WifiConfiguration();
tmpConfig.BSSID = sBSSID;
tmpCon开发者_StackOverflow社区fig.SSID = sSSID;
tmpConfig.status =WifiConfiguration.Status.ENABLED;
int netId =wifiManager.addNetwork(tmpConfig);
return wifiManager.enableNetwork(netId,true);
But, I keep getting false and the log is as follows :
E/wpa_supplicant( 7983): Line 0: failed to parse ssid 'A'.
D/MYWIFI (8191): false
Has anyone faced this problem earlier, and knows a solution?
Thanks, Pravein
Instead of
tmpConfig.SSID = sSSID;
assign as
tmpConfig.SSID = "\""+ sSSID +"\"";
In addion to Amitku's answer, You may have to run
wifiManager.disconnect();
before attempting to trying to enable your other network.
精彩评论