Некоторые файлы PDF, загруженные с веб-сайта, не открываются - PullRequest
0 голосов
/ 14 апреля 2020

В моем webView PDF-файлы, загруженные с сайтов, требующих входа, не открываются после их загрузки, но загруженные в противном случае всегда будут открываться. Пожалуйста, почему это так?

Мой класс менеджера загрузки:

        fileName = URLUtil.guessFileName(aUrl, contentDisposition, mimetype); //returns a string of the name of the file THE IMPORTANT PART

                DownloadManager.Request request = new DownloadManager.Request(Uri.parse(aUrl));
                request.allowScanningByMediaScanner();
                CookieManager cookieManager = CookieManager.getInstance();
                String cookie = cookieManager.getCookie(aUrl);
                request.addRequestHeader("Cookie", cookie);
                request.setMimeType("application/pdf");
                request.addRequestHeader("User-Agent", userAgent);
                Environment.getExternalStorageDirectory();
                request.setNotificationVisibility(DownloadManager.Request.VISIBILITY_VISIBLE_NOTIFY_COMPLETED);
                request.setDestinationInExternalPublicDir(Environment.DIRECTORY_DOWNLOADS, fileName);
                DownloadManager dm = (DownloadManager) getSystemService(DOWNLOAD_SERVICE);
                dm.enqueue(request);
                registerReceiver(onComplete, new IntentFilter(DownloadManager.ACTION_DOWNLOAD_COMPLETE));





    }


});
...