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...
Application Xamarin Forms Android. The application has a WebView element that displays different sites. On these sites, it is possible to download files. But the file cannot be downloaded via WebView.
The download manager is a service that can be used to handle downloads. Set the download URL and when the Download manager is invoked it will download the file in the background. It needs permission to write into storage and permission to access the Internet.
Go to the webpage where you want to download a file. Touch and hold what you want to download, then tap Download link or Download image. To see all the files you've downloaded to your device, open the Downloads app.
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With