获取手机所有连接管理对象

 

 

// 检查网络
public static boolean CheckNet(Context context)
{
try
{
ConnectivityManager connectivity = (ConnectivityManager) context.getSystemService(CONNECTIVITY_SERVICE);
if (connectivity != null)
{
NetworkInfo info = connectivity.getActiveNetworkInfo();
if (info != null && info.isConnected())
{
if (info.getState() == NetworkInfo.State.CONNECTED)
{
return true;
}
else
{
return false;
}
}
else
{
return false;
}
}
else
{
return false;
}
}
catch (Exception e)
{
return false;
}

posted on 2012-09-16 18:45  larryle  阅读(152)  评论(0)    收藏  举报