I am developing an application using Wifi in Android. Whenever I enter wrong password while connecting to wifi, I dont get any notification for invalid authentication. It just keeps on retrying to connect. Same behavior is found in wifi wireless setting.
Is there any way to find that Wifi Authentication has failed??
WifiManager.EXTRA_SUPPLICANT_ERROR -- I never get this..
This code works:
IntentFilter mIntentFilter = new IntentFilter();
mIntentFilter.addAction(WifiManager.SUPPLICANT_STATE_CHANGED_ACTION);
registerReceiver(receiverWifi, mIntentFilter);
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<<<<<<");
SupplicantState supl_state=((SupplicantState)intent.getParcelableExtra(WifiManager.EXTRA_NEW_STATE));
switch(supl_state){
case ASSOCIATED:Log.i("SupplicantState", "ASSOCIATED");
break;
case ASSOCIATING:Log.i("SupplicantState", "ASSOCIATING");
break;
case AUTHENTICATING:Log.i("SupplicantState", "Authenticating...");
break;
case COMPLETED:Log.i("SupplicantState", "Connected");
break;
case DISCONNECTED:Log.i("SupplicantState", "Disconnected");
break;
case DORMANT:Log.i("SupplicantState", "DORMANT");
break;
case FOUR_WAY_HANDSHAKE:Log.i("SupplicantState", "FOUR_WAY_HANDSHAKE");
break;
case GROUP_HANDSHAKE:Log.i("SupplicantState", "GROUP_HANDSHAKE");
break;
case INACTIVE:Log.i("SupplicantState", "INACTIVE");
break;
case INTERFACE_DISABLED:Log.i("SupplicantState", "INTERFACE_DISABLED");
break;
case INVALID:Log.i("SupplicantState", "INVALID");
break;
case SCANNING:Log.i("SupplicantState", "SCANNING");
break;
case UNINITIALIZED:Log.i("SupplicantState", "UNINITIALIZED");
break;
default:Log.i("SupplicantState", "Unknown");
break;
}
int supl_error=intent.getIntExtra(WifiManager.EXTRA_SUPPLICANT_ERROR, -1);
if(supl_error==WifiManager.ERROR_AUTHENTICATING){
Log.i("ERROR_AUTHENTICATING", "ERROR_AUTHENTICATING!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
}
}
}
}
<receiver
android:name=".MyActivity$WifiReceiver"
android:process=":remote" >
</receiver>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With