Androfee
Androfee

Reputation: 11

Downloading Web Page with Download Manager

I am Using Download Manager for Downloading Webpage URLS, which may have extension .txt/.pdf...Some Http Links like "www.abc.com" cant be opened once downloaded

The Following is the code I tried

DownloadManager mgr = (DownloadManager) getSystemService(Context.DOWNLOAD_SERVICE);
        uRl = uRl.replace("https://", "http://");
        Uri downloadUri = Uri.parse(uRl);

        DownloadManager.Request request = new DownloadManager.Request(downloadUri);

        request.setAllowedNetworkTypes(
                        DownloadManager.Request.NETWORK_WIFI
                                | DownloadManager.Request.NETWORK_MOBILE).setAllowedOverMetered(true)
                .setAllowedOverRoaming(true).setTitle("Files - " + "Downloading.. " + uRl)
                .setVisibleInDownloadsUi(true)
                .setNotificationVisibility(DownloadManager.Request.VISIBILITY_VISIBLE)
                .setMimeType(getMimeType(uRl))
                .setDestinationInExternalPublicDir(Environment.DIRECTORY_DOWNLOADS, "FilesFromApp/" + getFileName(uRl));
        downloadId = mgr.enqueue(request);

Upvotes: 0

Views: 69

Answers (0)

Related Questions