Code example for ConnectivityManager: Querying Network Reachability

Methods: getActiveNetworkInfogetBackgroundDataSetting

0
	 */ 
	private static boolean isNetworkAvailable(boolean isBackground,Context callingContext){
		ConnectivityManager manager = (ConnectivityManager)callingContext.getSystemService(Context.CONNECTIVITY_SERVICE);
		//If the request is in the background and the phone does not want us to do 
		//any background data transfer then respect that wish and bail. 
		if(isBackground && !manager.getBackgroundDataSetting())
			return false; 
		//if the current connection isn't ready for data then bail 
		//Apparently if there is no network, the network info returns null 
		NetworkInfo netInfo = manager.getActiveNetworkInfo();
		if(netInfo == null || manager.getActiveNetworkInfo().getState() != NetworkInfo.State.CONNECTED)
			return false; 
		return true; 
	} 
 
	/** 
	 * Get the XML document for the RSS feed 
	 * @return the XML Document for the feed on success, on error returns null 
	 */ 
	private static Document getDocument(){
		Document doc = null;