0
我要检查在Android的application.so网络连接检查我插入下面的代码网安卓
public boolean isNetworkAvailable() {
Context context = getApplicationContext();
ConnectivityManager connectivity = (ConnectivityManager)
context.getSystemService(Context.CONNECTIVITY_SERVICE);
NetworkInfo[] info = connectivity.getAllNetworkInfo();
if (info != null)
{
for (int i = 0; i < info.length; i++)
{
if (info[i].getState() == NetworkInfo.State.CONNECTED)
{
return true;
}
}
}
return false;
}
,当我在我的计算机中删除网络电缆程序crashed.but当我关闭飞行模式模拟器,它正确显示“NETWORK NOT AVAILABLE”。 我们如何检查?
使用'ADB logcat',DDMS,或在Eclipse中DDMS角度来考察logcat的,看看当你的“程序崩溃”产生的堆栈跟踪。 – CommonsWare 2010-10-15 12:56:26