I have a problem with this code it seams that it is working async and it returns false but too late because the code in the if statement seams to run before the check is completed in onReceve.
How can i make the check in onReceve finish first an then run the code in the if statement?
class WifiReceiver extends BroadcastReceiver {
@Override
public void onReceive(Context c, Intent intent) {
String action = intent.getAction();
if(action.equals(WifiManager.SUPPLICANT_STATE_CHANGED_ACTION)){
Log.d("WifiReceiver", ">>>>SUPPLICANT_STATE_CHANGED_ACTION<<<<<<");
int supl_error=intent.getIntExtra(WifiManager.EXTRA_SUPPLICANT_ERROR, -1);
if(supl_error==WifiManager.ERROR_AUTHENTICATING){
Log.i("ERROR_AUTHENTICATING", "ERROR_AUTHENTICATING!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
flag = false;
}
else {
flag = true;
}
}
}
}
if(flag){
//do something
}