Code example for DownloadManager

Methods: query

0
	@TargetApi(9) 
	boolean isDownloading(Context context)
	{ 
		DownloadManager dl = (DownloadManager) context
				.getSystemService(Context.DOWNLOAD_SERVICE);
		Cursor query = dl.query(new DownloadManager.Query()
				.setFilterByStatus(DownloadManager.STATUS_PENDING
						| DownloadManager.STATUS_RUNNING));
		 
		// are download going on? 
		if (query.getCount() > 0)
		{ 
	    	Log.i(TAG, query.getCount() + " downloads are running or pending");
	    	SetWifiStateService.scheduleRetryWifiOffAlarm(context);
	    	return true; 
		} 
		else 
		{ 
			Log.i(TAG, query.getCount() + " downloads are running or pending");
			return false; 
		}