我的應用程序在Android中使用wifi管理器,但是在情況下我面臨錯誤:: WIFI已打開但未通過身份驗證(與我們公司當時的WiFi用戶名和密碼),我的應用程序強制關閉,Android:我如何檢查WiFi是否已通過驗證
的代碼,我現在用的就是
try{
if (connectivityManager != null &&
(connectivityManager.getNetworkInfo(1).getState() == NetworkInfo.State.CONNECTED) ||
(connectivityManager.getNetworkInfo(0).getState() == NetworkInfo.State.CONNECTED))
{
//You are connected, do something online.
return true;
}
else if (connectivityManager.getNetworkInfo(0).getState() == NetworkInfo.State.DISCONNECTED ||
connectivityManager.getNetworkInfo(1).getState() == NetworkInfo.State.DISCONNECTED)
{
//Not connected.
//Toast.makeText(getApplicationContext(), "You must be connected to the internet", Toast.LENGTH_LONG).show();
loginTask.myPublishProgress("You must be connected to the internet");
return false;
}
}
catch(NullPointerException ae)
{
ae.printStackTrace();
loginTask.myPublishProgress("You must be connected to the internet");
}
你可以發佈你的logcat嗎? – itsrajesh4uguys 2013-05-07 05:50:28