switch (state) {
case COMPLETED:
case FOUR_WAY_HANDSHAKE:
//is it need to check if mScanResult is not empty it have a ssid and you can check the connect status? like this:
// boolean isConnectWithResult = mScanResult!=null&&isAlreadyConnected2(mWifiManager,mScanResult.SSID);
if (isConnectWithResult || isAlreadyConnected2(mWifiManager, ssid)) {
mWifiConnectionCallback.successfulConnect();
} else if (isAlreadyConnected(mWifiManager, of(mScanResult).next(scanResult -> scanResult.BSSID).get())) {
mWifiConnectionCallback.successfulConnect();
}
break;
case DISCONNECTED:
if (supl_error == WifiManager.ERROR_AUTHENTICATING) {
wifiLog("Authentication error...");
mWifiConnectionCallback.errorConnect(ConnectionErrorCode.AUTHENTICATION_ERROR_OCCURRED);
} else {
wifiLog("Disconnected. Re-attempting to connect...");
reEnableNetworkIfPossible(mWifiManager, mScanResult);
}
}
in WifiConnectionReceiver
switch (state) { case COMPLETED: case FOUR_WAY_HANDSHAKE: //is it need to check if mScanResult is not empty it have a ssid and you can check the connect status? like this: // boolean isConnectWithResult = mScanResult!=null&&isAlreadyConnected2(mWifiManager,mScanResult.SSID); if (isConnectWithResult || isAlreadyConnected2(mWifiManager, ssid)) { mWifiConnectionCallback.successfulConnect(); } else if (isAlreadyConnected(mWifiManager, of(mScanResult).next(scanResult -> scanResult.BSSID).get())) { mWifiConnectionCallback.successfulConnect(); } break; case DISCONNECTED: if (supl_error == WifiManager.ERROR_AUTHENTICATING) { wifiLog("Authentication error..."); mWifiConnectionCallback.errorConnect(ConnectionErrorCode.AUTHENTICATION_ERROR_OCCURRED); } else { wifiLog("Disconnected. Re-attempting to connect..."); reEnableNetworkIfPossible(mWifiManager, mScanResult); } }