Home DownloadManager does not start the download
Reply: 0

DownloadManager does not start the download

user1865 Published in March 18, 2018, 2:15 am

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() {
            public void onDownloadStart(String url, String userAgent, final String contentDisposition, final String mimeType, long contentLength) {
                DownloadManager.Request request = new DownloadManager.Request(Uri.parse(url));

                String cookies = CookieManager.getInstance().getCookie(url);
                request.addRequestHeader("cookie", cookies);
                request.addRequestHeader("User-Agent", userAgent);
                request.setDescription("Downloading file...");
                request.setTitle(URLUtil.guessFileName(url, contentDisposition, mimeType));
                request.setDestinationInExternalPublicDir(Environment.DIRECTORY_DOWNLOADS, URLUtil.guessFileName(url, contentDisposition, mimeType));
                DownloadManager dm = (DownloadManager) activity.getSystemService(DOWNLOAD_SERVICE);
                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!!

You need to login account before you can post.

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

© 2016 Powered by mzan.com design MATCHINFO