[問題] 關於Wifi連線時檢查密碼的問題已刪文
各位版友好,
如標題,我使用兩種情境(正確密碼/錯誤密碼)驗證是否會檢查密碼後連接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,請問是
否使用方式有錯誤呢?
--
※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 61.230.250.83 (臺灣)
※ 文章網址: https://www.ptt.cc/bbs/AndroidDev/M.1591702628.A.215.html
AndroidDev 近期熱門文章
PTT數位生活區 即時熱門文章