0

Hello everyone Iam new in android development i want to download an pdf file in my app webView I use this below code but when I try to open this the app redirect me to the my phone web browser how can i solve it and how can I download the pdf file in my webView

webView.loadUrl("https://drive.google.com/file/d/0B8q0tdiHCaVUc3RhcnRlcl9maWxl/view")
        
        webView.setDownloadListener { url, userAgent, contentDisposition, mimetype, contentLength ->

            val i = Intent(Intent.ACTION_VIEW)
            i.data = Uri.parse(url)
            startActivity(i)

}
Ivan Wooll
  • 4,145
  • 3
  • 23
  • 34
Akhilesh
  • 11
  • 1

1 Answers1

1

in HERE you have plenty of methods how to download file, but this link isn't pointing on PDF... it is pointing on some web app (Goodle Drive link), which can read and display PDF as own web content ("inside"), so when you start download this file you will get some web content/data. maybe worth to try to parse this stucture looking for pdf URL or maybe just provide strictly-to-pdf link (probably ending with .pdf) instead of this "web-viewer". then use one of methods described in linked SO topic/question

snachmsm
  • 17,866
  • 3
  • 32
  • 74