我的应用程序在 android 中使用 wifi 管理器,但我遇到错误的情况是::WIFI 已打开但未通过身份验证(使用我们公司的 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");
}