android webview中的HTML文件输入(android 4.4,kitkat) [英] HTML file input in android webview (android 4.4, kitkat)

查看:26
本文介绍了android webview中的HTML文件输入(android 4.4,kitkat)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在 android webview 上使用了 <input type="file">.由于这个线程,我让它工作了:WebView 中的文件上传

I was using the <input type="file"> on the android webview. I got it working thanks to this thread: File Upload in WebView

但是接受的答案(或任何其他答案)不再适用于 android 4.4 kitkat webview.

But the accepted answer (or any other) no longer works with android 4.4 kitkat webview.

有人知道怎么解决吗?

它也不适用于目标 18.

It doesn't work with target 18 either.

我查看了一些 android 4.4 源代码,似乎 WebChromeClient 没有改变,但我认为 setWebChromeClient 不再适用于 kitkat webview,或者至少不是 openFileChooser 函数.

I've looking some android 4.4 source code and it seems that the WebChromeClient hasn't changed, but I think the setWebChromeClient no longer works on the kitkat webview, or at least not the openFileChooser function.

推荐答案

更新 2:有一个更简单的插件可以与 phonegap/cordova 一起使用

Update 2: There is a simpler plugin to use with phonegap/cordova

https://github.com/MaginSoft/MFileChooser

更新:带有 Cesidio DiBenedetto 插件的示例项目

Update: Sample project with Cesidio DiBenedetto plugin

https://github.com/jcesarmobile/FileBrowserAndroidTest

我在 android 开源项目上打开了一个问题答案是:

I opened an issue on the android open source project and the answer was:

状态:按预期工作

不幸的是,openFileChooser 不是公共 API.我们正在开发未来 Android 版本中的公共 API.

unfortunately, openFileChooser is not a public API. We are working on a public API in future releases of Android.

对于使用 phonegap/cordova 的用户,此解决方法已发布在错误跟踪器上:

For those using phonegap/cordova, this workaround was posted on the bug tracker:

Cesidio DiBenedetto 添加了评论 - 28/Mar/14 01:27

Cesidio DiBenedetto added a comment - 28/Mar/14 01:27

大家好,我也遇到过这个问题,所以我写了一个Cordova FileChooser 插件暂时成为创可贴".基本上,在 Android 4.4(KitKat) 中,如之前的评论中所述,文件对话框没有打开.但是 onclick 事件仍然是启动,以便您可以调用 FileChooser 插件打开一个文件对话框,选择后,您可以设置一个变量包含文件的完整路径.此时,您可以使用FileTransfer 插件上传到您的服务器并挂接到onprogress 事件以显示进度.这个插件主要是配置对于 Android 4.4 所以我建议继续使用原生早期版本的 Android 的文件对话框.可能有问题使用插件,因为我还没有完全测试所有可能的场景许多设备,但我已将其安装在 Nexus 5 上并且运行良好.

Hey all, I've been experiencing this issue as well so I wrote a Cordova FileChooser plugin to a "band-aid" for the time being. Basically, in Android 4.4(KitKat), as mentioned in previous comments, the file dialog is not opened. However the onclick event is still fired on so you can call the FileChooser plugin to open a file dialog and upon selection, you can set a variable that contains the full path to the file. At this point, you can use the FileTransfer plugin to upload to your server and hook into the onprogress event to show progress. This plugin is mainly configured for Android 4.4 so I would recommend to continue to use the native file dialogs for earlier versions of Android. There might be issues with the plugin as I have not fully tested all possible scenarios on many devices, but I have installed it on a Nexus 5 and it worked fine.

https://github.com/cdibened/filechooser

未对其进行测试,因为我构建了自己的解决方法

Not tested it because I built my own workaround

来自 Chromium 开发人员的评论

A comment form a chromium developer

我们将在下一个专业中为 WebViewClient 添加一个公共 API释放以处理文件请求.

We will be a adding a public API to WebViewClient in next major release to handle file requests.

似乎他们现在认为这是一个错误,他们将修复它

It seems they consider it as a bug now and they are going to fix it

这篇关于android webview中的HTML文件输入(android 4.4,kitkat)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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