下载文件中的WebView [英] Download File inside WebView
本文介绍了下载文件中的WebView的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在我的Android应用程序中的web视图。当用户进入的WebView,然后点击链接下载文件时没有任何反应。
I have a webview in my Android Application. When user goes to webview and click a link to download a file nothing happens.
URL = "my url";
mWebView = (WebView) findViewById(R.id.webview);
mWebView.setWebViewClient(new HelloWebViewClient());
mWebView.getSettings().setDefaultZoom(ZoomDensity.FAR);
mWebView.loadUrl(URL);
Log.v("TheURL", URL);
如何启用下载一个web视图里面?如果我禁用web视图,使意图从应用程序中加载的URL链接broswer然后下载适用于无缝连接。
How to enable download inside a webview?? If I disable webview and enable the intent to load the url on broswer from application then download works seamlessly.
String url = "my url";
Intent i = new Intent(Intent.ACTION_VIEW);
i.setData(Uri.parse(url));
startActivity(i);
有人可以帮助我在这里。该页面加载没有问题,但链接到HTML页面一个图像文件没有工作....在此先感谢您的时间。
Can someone help me out here. The page loads without issue but the link to a image file in the html page is not working.... Thanks in advance for your time.
推荐答案
您是否尝试过?
mWebView.setDownloadListener(new DownloadListener() {
public void onDownloadStart(String url, String userAgent,
String contentDisposition, String mimetype,
long contentLength) {
Intent i = new Intent(Intent.ACTION_VIEW);
i.setData(Uri.parse(url));
startActivity(i);
}
});
这篇关于下载文件中的WebView的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文