在我的网页视图中,我有这段代码。当我点击我的网络视图应用程序中的链接时,停止显示再次尝试打开应用程序。
myWebView.setDownloadListener(new DownloadListener() {
public void onDownloadStart(String url, String userAgent, String
contentDisposition, String mimetype, long contentLength) {
DownloadManager.Request request = new
DownloadManager.Request(Uri.parse(url));
CookieManager cookieManager = CookieManager.getInstance();
String cookie =
cookieManager.getCookie("https://learntatatrusts.org/");
request.addRequestHeader("Cookie", cookie);
request.allowScanningByMediaScanner();
Environment.getExternalStorageDirectory();
getApplicationContext().getFilesDir().getPath();
request.setNotificationVisibility(DownloadManager.Request.
VISIBILITY_VISIBLE_NOTIFY_COMPLETED);
request.setDestinationInExternalPublicDir(Environment.
DIRECTORY_DOWNLOADS, "download");
DownloadManager dm = (DownloadManager)
getSystemService(DOWNLOAD_SERVICE);
dm.enqueue(request);
}
});
答案 0 :(得分:1)
我认为您还需要在运行时请求权限,不仅仅在Android Manifest文件中。你可以在这里查看:
https://developer.android.com/training/permissions/requesting.html#explain
在这里:
答案 1 :(得分:0)
Neither user 10083 nor current process has android.permission.WRITE_EXTERNAL_STORAGE
您是否尝试在Manifest中申请WRITE_EXTERNAL_STORAGE权限?