/**
* 判断当前网络是否可用
* */
public boolean judgeNetAvailable()
{
ConnectivityManager manager = (ConnectivityManager) getSystemService(CONNECTIVITY_SERVICE);
NetworkInfo networkinfo = manager.getActiveNetworkInfo();
if (networkinfo == null || !networkinfo.isAvailable()) //网络不可用的情况
{
return false;
}
else
{
return true;
}
}
startActivity(new Intent(Settings.ACTION_WIRELESS_SETTINGS));//进入网络配置界面
(鲁大)
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
判断网络是否可用
最新推荐文章于 2024-01-06 14:21:44 发布