[英]How to download a pdf from an Android Webview?
I have an application that launches a webivew
. 我有一个启动
webivew
的应用程序。 When I click on the PDF
links in the webview
, download of that PDF
should start. 当我单击
webview
的PDF
链接时,应该开始下载该PDF
。 I am able to do this with the following code. 我可以使用以下代码来做到这一点。
view.getContext().startActivity(
new Intent(Intent.ACTION_VIEW, Uri.parse(url)));
Here the moment the download starts my current webview activity
is closed, as I give startActivity()
. 从此处下载开始我当前的
webview activity
关闭,因为我指定了startActivity()
。
But I want user to be on the webview
itself and download should start in the background without vanishing the webview
. 但是我希望用户可以使用
webview
本身,并且下载应该在后台开始而不会消失webview
。 What is the way around for that? 那是怎么回事? Kindly help.
请帮助。
You can do one thing. 你可以做一件事。 The moment the PDF download starts, then see to it that your webview activity is prevented from onDestroy() or finish().
PDF下载开始的那一刻,然后确认onDestroy()或finish()阻止了Webview活动。
Then u can start the download in background and also retain the Webview activity. 然后,您可以在后台开始下载,还可以保留Webview活动。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.