Supporting resumable HTTP-downloads through an ASHX handler?

Thanks icktoofay for getting me started, here’s a complete example to save other developers some time: Disk Example /// <summary> /// Writes the file stored in the filesystem to the response stream without buffering in memory, ideal for large files. Supports resumable downloads. /// </summary> /// <param name=”filename”>The name of the file to write to … Read more

DownloadManager.ACTION_DOWNLOAD_COMPLETE broadcast receiver receiving same download id more than once with different download statuses in Android

This is a reported bug see: http://code.google.com/p/android/issues/detail?id=18462 The way around I found is to verify if the download was a success, if not ditch the intent or re-queue the file if it was never downloaded… Lost a couple of hours figuring that one 🙁 ** Edit: adding code example ** /** * Check if download … Read more

Set custom folder Android Download Manager

check below code: its save file in “sdcard/dhaval_files/”. just replace your folder name and give permission write_external_storage in android manifest file. public void file_download(String uRl) { File direct = new File(Environment.getExternalStorageDirectory() + “/dhaval_files”); if (!direct.exists()) { direct.mkdirs(); } DownloadManager mgr = (DownloadManager) this.getSystemService(Context.DOWNLOAD_SERVICE); Uri downloadUri = Uri.parse(uRl); DownloadManager.Request request = new DownloadManager.Request( downloadUri); request.setAllowedNetworkTypes( DownloadManager.Request.NETWORK_WIFI … Read more

Android DownloadManager Progress

I am looking for a better way of doing this also, but so far I am planning to just poll for progress every 1sec or so. DownloadManager mgr = (DownloadManager) context.getSystemService(Context.DOWNLOAD_SERVICE); long id = mgr.enqueue(request); DownloadManager.Query q = new DownloadManager.Query(); q.setFilterById(id); Cursor cursor = mgr.query(q); cursor.moveToFirst(); int bytes_downloaded = cursor.getInt(cursor.getColumnIndex(DownloadManager.COLUMN_BYTES_DOWNLOADED_SO_FAR)); cursor.close(); Edit: A FileObserver can … Read more