下载文件到Android的WebView(不下载事件或了HTTPClient在code) [英] Downloading a file to Android WebView (without the download event or HTTPClient in the code)

查看:110
本文介绍了下载文件到Android的WebView(不下载事件或了HTTPClient在code)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是更多的问题出于好奇比需要解决的一个现实问题。我做了一个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

这篇关于下载文件到Android的WebView(不下载事件或了HTTPClient在code)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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