Home DownloadManager does not start the download
Reply: 1

DownloadManager does not start the download

FJ Garrido
1#
FJ Garrido Published in 2017-11-14 21:40:56Z

im using downloadManager but it doesnt download nothing. When i start to download the file, it is placed in queue list and never start the download. This is my code:

webView.setDownloadListener(new DownloadListener() {
            @Override
            public void onDownloadStart(String url, String userAgent, final String contentDisposition, final String mimeType, long contentLength) {
                DownloadManager.Request request = new DownloadManager.Request(Uri.parse(url));

                request.setMimeType(mimeType);
                //------------------------COOKIE!!------------------------
                String cookies = CookieManager.getInstance().getCookie(url);
                request.addRequestHeader("cookie", cookies);
                //------------------------COOKIE!!------------------------
                request.addRequestHeader("User-Agent", userAgent);
                request.setDescription("Downloading file...");
                request.setTitle(URLUtil.guessFileName(url, contentDisposition, mimeType));
                request.allowScanningByMediaScanner();
                request.setNotificationVisibility(DownloadManager.Request.VISIBILITY_VISIBLE_NOTIFY_COMPLETED);
                request.setDestinationInExternalPublicDir(Environment.DIRECTORY_DOWNLOADS, URLUtil.guessFileName(url, contentDisposition, mimeType));
                DownloadManager dm = (DownloadManager) activity.getSystemService(DOWNLOAD_SERVICE);
                dm.enqueue(request);
                Toast.makeText(activity.getApplicationContext(), "Downloading File", Toast.LENGTH_LONG).show();       
            }
        });

If i debbug, all values seem correct. This exact code work with Android 6.0, but when i try it with Android 7.0 doesnt work.

Any help?

Thank you very much!!

heisen
2#
heisen Reply to 2017-11-14 21:59:28Z

Are you asking for the WRITE_EXTERNAL_STORAGE permission?

You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.314695 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO