0

I was able to use DownloadManager to download HTTP request but I am unable to find any documentation/method regarding how can we use DownloadManager with HTTPS.

public long downloadFile(String fileUrl, String filename, String description, String token) {
    Uri uri = Uri.parse(fileUrl);
    DownloadManager.Request request = new DownloadManager.Request(uri);
    if (!TextUtils.isEmpty(filename))
        request.setTitle(filename);
    if (!TextUtils.isEmpty(description))
        request.setDescription(description);

    request.setDestinationInExternalPublicDir(Environment.DIRECTORY_DOWNLOADS, filename);
    request.allowScanningByMediaScanner();
    request.setVisibleInDownloadsUi(true);
    request.addRequestHeader("authorization", token);
    request.setNotificationVisibility(DownloadManager.Request.VISIBILITY_VISIBLE_NOTIFY_COMPLETED);
    return mDownloadManager.enqueue(request);
}
Cœur
  • 37,241
  • 25
  • 195
  • 267
Avinash Shinde
  • 199
  • 2
  • 12

0 Answers0