各位版友好,
如标题,我使用两种情境(正确密码/错误密码)验证是否会检查密码后连接AP,
接到WifiManager.SUPPLICANT_STATE_CHANGE_ACTION广播后,先印出SupplicantState,再
检查intent中的WifiManager.EXTRA_SUPPLICANT_ERROR字段,Receiver如下:
BroadcastReceiver Receiver=new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
String action=intent.getAction();
if (action.equals(WifiManager.SUPPLICANT_STATE_CHANGED_ACTION))
{
SupplicantState
supplicantState=(SupplicantState)intent.getParcelableExtra(WifiManager.EXTRA_NEW_STATE);
switch(supplicantState)
{
case ASSOCIATED:
Log.i(TAG,"Associated.");
break;
case ASSOCIATING:
Log.i(TAG,"Associating");
break;
case AUTHENTICATING:
Log.i(TAG,"Authenticating");
break;
case COMPLETED:
Log.i(TAG,"Connected");
break;
case DISCONNECTED:
Log.i(TAG,"Disconnected");
break;
case DORMANT:
Log.i(TAG,"Dormant");
break;
case FOUR_WAY_HANDSHAKE:
Log.i(TAG,"FOUR_WAY_HANDSHAKE");
break;
case GROUP_HANDSHAKE:
Log.i(TAG,"GROUP_HANDSHAKE");
break;
case INACTIVE:
Log.i(TAG,"INACTIVE");
break;
case INTERFACE_DISABLED:
Log.i(TAG,"INTERFACE_DISABLED");
break;
case INVALID:
Log.i(TAG,"INVALID");
break;
case SCANNING:
Log.i(TAG,"SCANNING");
break;
case UNINITIALIZED:
Log.i(TAG,"UNINITIALIZED");
break;
default:
Log.i(TAG,"Unknown");
break;
}
int
error=intent.getIntExtra(WifiManager.EXTRA_SUPPLICANT_ERROR,-1);
if (error==WifiManager.ERROR_AUTHENTICATING)
Log.i(TAG,"Wrong password");
}
}
};
使用正确密码或错误密码登入时SupplicantState都无印出AUTHENTICATING的Log,请问是
否使用方式有错误呢?