I was going to put this in a comment but it's too long for such, so I put it here:
Until API 28 there was an int called ERROR_AUTHENTICATING
in class WifiManager
, whose docs you can see here .
If you want the app to be compatible with the newer versions of android, you can use the class WifiInfo
, which you can see here , and use a code such that this:
//Si asi da error de sintaxis, llama a esta funcion utilizando el contexto de la app
//Algo asi: WifiInfo redInfo = getBaseContext().getConnectionInfo();
WifiInfo redInfo = getConnectionInfo();
String WifiSSID = redInfo.getBSSID();
//Si el valor de WifiSSID es "<unknown ssid>" no está conectado/ha fallado la conexion
if(WifiSSID.equals("<unknown ssid>")) {
//Hacer algo en base al error
} else {
//No hay error, todo correcto
}
I would like to emphasize that, according to the docs WifiManager
:
This class should only be obtained from the context of the application, not from another to avoid memory loss in the process that executes it.