Created
January 25, 2014 10:01
-
-
Save 4gray/8614247 to your computer and use it in GitHub Desktop.
DownloadManager [Android]
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* 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