判断网络是否可用

	/**
	 * 判断当前网络是否可用
	 * */
	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"/>

你可能感兴趣的:(网络)