Download file inside WebView
android, attachment, download, webview
Solution
Have you tried?
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);
}
});
Example Link: Webview File Download - Thanks @c49
Problem
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); ``` How to enable download inside a webview? If I disable webview and enable the intent to load the URL on browser from application then download works seamlessly. ``` String url = "my url"; Intent i = new Intent(Intent.ACTION_VIEW); i.setData(Uri.parse(url)); startActivity(i); ``` 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...