小编Aka*_*ash的帖子

如何下载受 NTLM 身份验证保护的文件

我曾尝试使用 Android 的 DownloadManager apis 进行下载,但未能成功。

这是我的示例代码,它返回给我下载失败。

webView.setDownloadListener(new DownloadListener() {
        @Override
        public void onDownloadStart(String url, String userAgent, String contentDisposition, String mimetype, long contentLength) {
            String filename = URLUtil.guessFileName(url, contentDisposition, mimetype);
            DownloadManager.Request request = new DownloadManager.Request(
                    Uri.parse(url));
            request.allowScanningByMediaScanner();
            request.setNotificationVisibility(DownloadManager.Request.VISIBILITY_VISIBLE_NOTIFY_COMPLETED); //Notify client once download is completed!
            request.setDestinationInExternalPublicDir(Environment.DIRECTORY_DOWNLOADS, filename);
            DownloadManager dm = (DownloadManager) MainActivity.this.getSystemService(MainActivity.this.DOWNLOAD_SERVICE);
            dm.enqueue(request);
        }
    });
Run Code Online (Sandbox Code Playgroud)

android android-download-manager ntlm-authentication

5
推荐指数
1
解决办法
152
查看次数