Skip to content
Advertisement

Download file in Webview

I’m using webview in an Android application. I am trying to download a .pdf file, however when the link is clicked through the application the .pdf file name is changed to “1rcPnhg9_rSes92BiQPotVjXuEAfFnyrf.pdf”, and is not saved with the original file name.

How to make webview save the file with the original name? At the moment the webview is saving the file using the ID as the name.

Used link: https://drive.google.com/uc?export=download&id=1rcPnhg9_rSes92BiQPotVjXuEAfFnyrf

WebView:

JavaScript

Permissions in Manifest:

JavaScript

Advertisement

Answer

Here a test with your link (in Kotlin). If you need a Java example, please, let me know:

JavaScript

image abuot download

Java code:

JavaScript
Advertisement