【发布时间】:2019-05-09 15:18:50
【问题描述】:
我有一个带有下载按钮的 Webview Android 应用程序,它尝试从 S3 存储桶下载图像。就像半年以前,一切正常,但突然停止工作。如果我转到网站的浏览器版本,一切仍然有效。所以我认为这与应用程序有关。
我有一个 addDownloadListener 并添加到了 android 清单中。
下面是我的 addDownloadListener:
私人无效 addDownloadListener() { TurbolinksSession.getDefault(this) .activity(这个) .适配器(这个) .view(turbolinksView) .getWebView() .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) getSystemService(DOWNLOAD_SERVICE);
dm.enqueue(request);
Toast.makeText(getApplicationContext(), "Download is gestart", //To notify the Client that the file is being downloaded
Toast.LENGTH_LONG).show();
}
});
}
当我点击链接时,这是日志猫中的输出:
E: [] mConsumerName == NULL!!!!!! 2019-05-10 11:00:53.606? E:onTransact 在代码中是:103
2019-05-10 10:45:51.840 ? E: win=Window{104d4cf u0 com.app.name.here.MainActivity} destroySurfaces: appStopped=true win.mWindowRemovalAllowed=false win.mRemoveOnExit=false
【问题讨论】:
-
听起来授权已过期。我没有看到您在此处向 s3 发送身份验证令牌;检查文件或容器本身的权限。
-
当然,尝试通过 CURL(或邮递员)下载图像 - 或者将 Fiddler 设置为代理,看看是否还有其他事情发生。
-
@Micromuncher 在这种情况下我该怎么做?
-
这怎么可能是问题所在?在浏览器上它仍然可以正常工作。
标签: java android image webview download