Android DownloadManager.Query - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Android DownloadManager.Query class.

This code example shows how to use the following methods:setFilterById
    private int getDownloadFailureReason(long id) {
        return getDownloadQueryAsInt(id, DownloadManager.COLUMN_REASON);
    } 
 
    private int getDownloadQueryAsInt(long id, String column) {
        Query query = new Query();
        query.setFilterById(id);
 
        Cursor c = downloadManager.query(query);
        if (!c.moveToFirst()) {
            return -1; 
        } 
 
        int columnIndex = c.getColumnIndex(column);
        return c.getInt(columnIndex);
    } 
 
    public interface DownloadCallback { 
        void onStart(String path);
        void onCancel(); 
5
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:setFilterById, setFilterByStatus
    @Override 
    public void onReceive(Context context, Intent intent) {
        DownloadManager mgr = (DownloadManager)context.getSystemService(Context.DOWNLOAD_SERVICE);
        long id = intent.getLongExtra("extra_download_id", -1);
 
        Query q = new Query();
        q.setFilterById(id);
        q.setFilterByStatus(DownloadManager.STATUS_SUCCESSFUL | DownloadManager.STATUS_FAILED);
 
        Cursor cursor = mgr.query(q);
        if (cursor.getCount() < 1) {
            cursor.close();
            return; 
        } 
 
        cursor.moveToFirst();
        int status = cursor.getInt(cursor.getColumnIndex(DownloadManager.COLUMN_STATUS));
        int reason = cursor.getInt(cursor.getColumnIndex(DownloadManager.COLUMN_REASON));
        String mediaType = cursor.getString(cursor.getColumnIndex(DownloadManager.COLUMN_MEDIA_TYPE));
        cursor.close();
5
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:setFilterById, setFilterByStatus
			return; 
		} 
		 
		DownloadManager dm = (DownloadManager) ctx.getSystemService(Context.DOWNLOAD_SERVICE);
	 
		Query query = new Query();
		query.setFilterById( downloadKey );
		query.setFilterByStatus( DownloadManager.STATUS_SUCCESSFUL );
		 
		Cursor cursor = dm.query(query);
		 
		if ( cursor.moveToNext() ){
			Log.d(TAG, "Clicked download successful completed.");
		}else{ 
			Log.d(TAG, "clicking on a download that is not complete. Just let us have patience ...");
		}				 
	} 
} 
5
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:setFilterById, setFilterByStatus
			return; 
		} 
		 
		DownloadManager dm = (DownloadManager) context.getSystemService( Context.DOWNLOAD_SERVICE );
		 
		Query query = new Query();
		query.setFilterById(downloadKey);
		query.setFilterByStatus( DownloadManager.STATUS_SUCCESSFUL );
 		 
		Cursor cursor = dm.query(query);		
  
		if ( cursor.moveToFirst() ){
	  
			DownloadDao downloadDao = new DownloadDao(context);
			ArticleDownloaded articleDownloaded = downloadDao.getById( downloadKey );
			if ( articleDownloaded == null ){
				return; 
			} 
 
			articleDownloaded = populeArticleDownloadedFromCursor(articleDownloaded, cursor);
5
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:setFilterById, setFilterByStatus
			return; 
		} 
		 
		DownloadManager dm = (DownloadManager) context.getSystemService( Context.DOWNLOAD_SERVICE );
		 
		Query query = new Query();
		query.setFilterById(downloadKey);
		query.setFilterByStatus( DownloadManager.STATUS_SUCCESSFUL );
 		 
		Cursor cursor = dm.query(query);		
  
		if ( cursor.moveToFirst() ){
	  
			DownloadDao downloadDao = new DownloadDao(context);
			ArticleDownloaded articleDownloaded = downloadDao.getById( downloadKey );
			if ( articleDownloaded == null ){
				return; 
			} 
 
			articleDownloaded = populeArticleDownloadedFromCursor(articleDownloaded, cursor);
5
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:setFilterById
            PendingDownload download = pendingDownloads.get(id);
            File downloaded = new File(download.getItem().getPathToSave());
 
            DownloadManager dm = (DownloadManager) context.getSystemService(Context.DOWNLOAD_SERVICE);
 
            Query query = new Query();
            query.setFilterById(id);
            Cursor c = dm.query(query);
            System.out.println("\nFinished[" + id + "]: " + downloaded);
 
            if (c.moveToFirst())
            { 
                int statusIndex = c.getColumnIndex(DownloadManager.COLUMN_STATUS);
                int statusReason = c.getColumnIndex(DownloadManager.COLUMN_REASON);
                // int localUri = 
                // c.getColumnIndex(DownloadManager.COLUMN_LOCAL_URI); 
 
                if (DownloadManager.STATUS_SUCCESSFUL == c.getInt(statusIndex))
                { 
                    if (download.getAction() != null)
4
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:setFilterById
		@Override 
		public void onReceive(Context context, Intent intent) { 
			 
			if (DownloadManager.ACTION_DOWNLOAD_COMPLETE.equals(intent.getAction())) { 
				 
                Query query = new Query(); 
                query.setFilterById(enqueue); 
                Cursor cursor = downloadManager.query(query); 
                 
                if (cursor.moveToFirst()) { 
                    int columnIndex = cursor.getColumnIndex(DownloadManager.COLUMN_STATUS); 
                     
                    if (DownloadManager.STATUS_SUCCESSFUL == cursor.getInt(columnIndex)) { 
                        String uriString = cursor.getString(cursor.getColumnIndex(DownloadManager.COLUMN_LOCAL_URI)); 
                        String fileName = cursor.getString(cursor.getColumnIndex(DownloadManager.COLUMN_LOCAL_FILENAME)); 
                         
                        // 
                        //	TODO -- put the database where it needs to go so it can be accessed as a sqlite database properly 
                        // 
                    } 
4
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:setFilterById
        public void onReceive(Context context, Intent intent) { 
            String action = intent.getAction(); 
            if (DownloadManager.ACTION_DOWNLOAD_COMPLETE.equals(action)) { 
                long downloadId = intent.getLongExtra( 
                        DownloadManager.EXTRA_DOWNLOAD_ID, 0); 
                Query query = new Query(); 
                query.setFilterById(enqueue); 
                Cursor c = dm.query(query); 
                if (c.moveToFirst()) { 
                    int columnIndex = c 
                            .getColumnIndex(DownloadManager.COLUMN_STATUS); 
                    if (DownloadManager.STATUS_SUCCESSFUL == c 
                            .getInt(columnIndex)) { 
 
                    } else if(DownloadManager.ERROR_FILE_ALREADY_EXISTS == c.getInt(columnIndex)){ 
                    	Toast.makeText(Download.this, "This file already Exists!", Toast.LENGTH_LONG); 
                    } 
                } 
            } 
        } 
4
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:setFilterById
	private final DownloadedFilesList	downloadedFilesList	= new DownloadedFilesList();
 
 
	private Uri getFileUri(final long reference, final String columnIndex)
	{ 
		final Query myDownloadQuery = new Query();
		myDownloadQuery.setFilterById(reference);
 
		final Cursor myDownload = downloadManager.query(myDownloadQuery);
		if (myDownload.moveToFirst())
		{ 
			final int fileUriIdx = myDownload.getColumnIndex(columnIndex);
			final String fileUri = myDownload.getString(fileUriIdx);
 
			if (!"".equals(fileUri) && fileUri != null)
			{ 
				return Uri.parse(fileUri);
			} else 
			{ 
				return null; 
4
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:setFilterById
		String action = intent.getAction();
		if (DownloadManager.ACTION_DOWNLOAD_COMPLETE.equals(action)) {
			long downloadId = intent.getLongExtra(
					DownloadManager.EXTRA_DOWNLOAD_ID, 0);
			if (downloadId == enqueued) {
				Query query = new Query();
				query.setFilterById(enqueued); // dlid
				Cursor c = mManager.query(query);
				if (c.moveToFirst()) {
					int columnIndex = c
							.getColumnIndex(DownloadManager.COLUMN_STATUS);
					if (DownloadManager.STATUS_SUCCESSFUL == c
							.getInt(columnIndex)) {
						String uriString = c
								.getString(c
										.getColumnIndex(DownloadManager.COLUMN_LOCAL_URI));
						final Uri fileUri = Uri.parse(uriString);
						submenu.addDecodingJob(fileUri, item.getGameName(),
								item);
						c.close();
5
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java

Related Android DownloadManager.Query Questions & Answers:

See Code Examples for Android DownloadManager.Query Methods: