DownloadManager remove - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for DownloadManager remove method.

This code example shows how to use the following methods:remove
					.getDefaultSharedPreferences(context);
			DownloadManager dm = (DownloadManager) context
					.getSystemService(Context.DOWNLOAD_SERVICE);
 
				try { 
					dm.remove(prefs.getLong("otadownloadid", -1));
					new OTA_updates().afterdownload(context);
				} catch (Exception e) {
				} 
		} 
	} 
} 
4
CodeRank
This code example shows how to use the following methods:query, remove
        }    
    };    
    private void queryDownloadStatus() {    
        DownloadManager.Query query = new DownloadManager.Query();   
        query.setFilterById(dmId);   
        Cursor c = downloadManager.query(query);   
        if(c.moveToFirst()) {   
            int status = c.getInt(c.getColumnIndex(DownloadManager.COLUMN_STATUS));   
            switch(status) {   
            case DownloadManager.STATUS_PAUSED:   
                Log.v("down", "STATUS_PAUSED");  
            case DownloadManager.STATUS_PENDING:   
                Log.v("down", "STATUS_PENDING");  
            case DownloadManager.STATUS_RUNNING:   
                //正在下载,不做任何事情   
                Log.v("down", "STATUS_RUNNING");  
                break;    
            case DownloadManager.STATUS_SUCCESSFUL:   
                //完成   
                Log.v("down", "下载完成");  

4
CodeRank
This code example shows how to use the following methods:query, remove
            DownloadManager.Query q = new DownloadManager.Query();
            q.setFilterById(id);
 
            int reason = 0;
 
            Cursor c = dm.query(q);
            if (c != null && c.moveToFirst()) {
                if (c.getInt(c.getColumnIndex(DownloadManager.COLUMN_STATUS)) == DownloadManager.STATUS_FAILED) {
                    reason = c.getInt(c.getColumnIndex(DownloadManager.COLUMN_REASON));
                    String uri = c.getString(c.getColumnIndex(DownloadManager.COLUMN_URI));
                    dm.remove(id);
 
                    String title = c.getString(c.getColumnIndex(DownloadManager.COLUMN_TITLE));
 
                    title = title.replaceAll("[^a-zA-Z0-9]+", "");
 
//                    Intent downloadIntent = new Intent(context, DownloadService.class); 
//                    downloadIntent.putExtra(DownloadService.URL, uri); 
//                    downloadIntent.putExtra(DownloadService.ID, id); 
//                    downloadIntent.putExtra(DownloadService.TITLE, title); 
4
CodeRank
This code example shows how to use the following methods:remove
		}); 
 
		cancel.setOnClickListener(new View.OnClickListener() {
 
			public void onClick(View v) {
				manager.remove(reference);
			} 
		}); 
	} 
 
	BroadcastReceiver receiver = new BroadcastReceiver() {
 
		@Override 
		public void onReceive(Context context, Intent intent) { 
			long refCompleted = intent.getLongExtra( 
					DownloadManager.EXTRA_DOWNLOAD_ID, -1); 
			if (refCompleted == reference) { 
				// downloading completed 
				// Toast.makeText(getApplicationContext(), 
				// "Downloading Completed!", Toast.LENGTH_LONG).show(); 
4
CodeRank
This code example shows how to use the following methods:remove
 
            builder.setNegativeButton(
                    R.string.remove_download, new DialogInterface.OnClickListener() {
                        @Override 
                        public void onClick(DialogInterface dialog, int which) {
                            dm.remove(id);
                        } 
                    }); 
 
            return builder.create();
        } 
 
        @Override 
        public void onDismiss(DialogInterface dialog) {
            super.onDismiss(dialog);
            getActivity().finish();
        } 
    } 
 
    public static class FailedDialogFragment extends DialogFragment {
4
CodeRank
This code example shows how to use the following methods:query, remove
	}	 
 
	private boolean isDownloading(long syncid) {
		DownloadManager.Query query = new DownloadManager.Query();
		query.setFilterById(syncid);
		Cursor cursor = downloadManager.query(query);
		 
		try { 
			if (cursor.moveToFirst()) {
				int status =cursor.getInt(cursor.getColumnIndex(DownloadManager.COLUMN_STATUS));
				if (status == DownloadManager.STATUS_FAILED) {
					downloadManager.remove(syncid);
					return false; 
				} 
			} 
			 
		} finally { 
			cursor.close();
		} 
		return true; 
4
CodeRank

Related DownloadManager remove Questions & Answers:

remove Method Overview
Cancel downloads and remove them from the download manager.
See Code Examples for other Android DownloadManager Methods: