如何下载从Android web视图PDF文件? [英] How to download a pdf from an Android Webview?

查看:187
本文介绍了如何下载从Android web视图PDF文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个启动一个webivew的应用程序。当我点击了网页视图的PDF链接,即PDF下载应该开始。我可以用下面的code做到这一点。

I have an application that launches a webivew. When I click on the PDF links in the webview, download of that PDF should start. I am able to do this with the following code.

view.getContext()。startActivity(
                            新意图(Intent.ACTION_VIEW,Uri.parse(URL)));

view.getContext().startActivity( new Intent(Intent.ACTION_VIEW, Uri.parse(url)));

下面的下载开始我目前的WebView活动的瞬间被关闭,因为我给startActivity()。

Here the moment the download starts my current webview activity is closed, as I give startActivity().

但我想用户要上的WebView本身,下载应该在后台启动时不消失web视图。什么是周围的道路?请帮助。

But I want user to be on the webview itself and download should start in the background without vanishing the webview. What is the way around for that? Kindly help.

推荐答案

您可以做一件事。 PDF格式下载开始的那一刻,然后看到它,你的WebView活动是$ P $来自的onDestroy pvented()或完成()。

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().

那么在哪里开始下载的背景,还保留了网页视图的活动。

Then u can start the download in background and also retain the Webview activity.

这篇关于如何下载从Android web视图PDF文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆