Answer the question
In order to leave comments, you need to log in
Wifi connection status?
Hello. Tell me please. I am connecting to Wifi, how to understand the status - connected to the network, or an error. If an error, then why: maybe the password is wrong?
private void connectToWifi(final String networkSSID, final String networkPassword) {
int netID = -1;
String confSSID = String.format("\"%s\"", networkSSID);
String confPassword = String.format("\"%s\"", networkPassword);
netID = getExistingNetworkID(confSSID, netID);
if (netID == -1) {
Log.d(TAG,"New wifi config added");
WifiConfiguration conf = new WifiConfiguration();
conf.SSID = confSSID;
conf.preSharedKey = confPassword;
netID = wifiManager.addNetwork(conf);
}
wifiManager.disconnect();
wifiManager.enableNetwork(netID, true);
wifiManager.reconnect();
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question