下载文件到Android的WebView(不下载事件或了HTTPClient在code)事件、文件、Android、WebView

2023-09-08 08:42:20 作者:止步于喜欢

这是更多的问题出于好奇比需要解决的一个现实问题。我做了一个Android应用程序,其中包含一个web视图。我用的应该重写URL方法使任何一个环节单击了将在web视图中打开。

This is more a question out of curiosity than a real problem that needs to be solved. I made an Android app which contains a WebView. I used the should override URL method so that any link clicked would be opened in the WebView.

后来我决定,一个文件将被从服务器向用户设备下载。不幸的是我从来没有见过的setDownloadListener方法。当用户点击一个链接现在还不是开始下载。

Later I decided that a file would be downloaded from the server to the user device. Unfortunately I had not seen the setDownloadListener method before. When the user clicks a link now the download is not initiated.

据我可以告诉我需要更新适当的code即下载监听器或HttpClient的,这是正常的应用程序。

As far as I can tell I need to update the app with proper code i.e the download listener or a HttpClient, which is okay.

(虽然听起来像一个白痴的风险),我想知道,有没有办法通过从服务器的操作,我可以做的WebView下载一个文件,而无需一个code修改?

(At the risk of sounding like an idiot) I am wondering, is there any way through an action from the server that I can make the WebView download a file without a code change?

我想这功能在这可能是为什么web视图打开浏览器下载文件的web视图。只是在想,也许我错过了一些东西,使其工作。我是pretty的新本。

I guess that functionality is not in the WebView which is probably why the WebView opens a browser to download a file. Just thinking maybe I have missed something to make it work. I am pretty new to this.

推荐答案

我想的WebView将下载和渲染只有text / html的内容和multipart内容。而其余的将被引导到你所看到下载客户端。

I think webview will download and render only text/html contents and the multiparts. And the rest will be directed to a download client which you are seeing.

Herojit