Skip to content

Instantly share code, notes, and snippets.

@4gray
Created January 25, 2014 10:01
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save 4gray/8614247 to your computer and use it in GitHub Desktop.
Save 4gray/8614247 to your computer and use it in GitHub Desktop.
DownloadManager [Android]
/**
* Start Download
*/
public void startDownload(String link, String filename) {
Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS).mkdirs();
DownloadManager mManager = (DownloadManager) getSystemService(Context.DOWNLOAD_SERVICE);
DownloadManager.Request mRqRequest = new DownloadManager.Request(Uri.parse(link));
mRqRequest.setDescription("Download file...");
mRqRequest.setDestinationInExternalPublicDir(Environment.DIRECTORY_DOWNLOADS,filename);
mRqRequest.setNotificationVisibility(DownloadManager.Request.VISIBILITY_VISIBLE_NOTIFY_COMPLETED);
long idDownLoad=mManager.enqueue(mRqRequest);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment