WebView Android 4.0 文件上传 [英] WebView Android 4.0 file upload
本文介绍了WebView Android 4.0 文件上传的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
它只是不工作.
我正在这样做
webView.setWebChromeClient(new WebChromeClient() {
public void openFileChooser(ValueCallback<Uri> uploadFile) {
System.out.println("openFileChooser");
mUploadMessage = uploadFile;
Intent i = new Intent(Intent.ACTION_GET_CONTENT);
i.addCategory(Intent.CATEGORY_OPENABLE);
i.setType("file/*");
PresentationActivity.this.startActivityForResult(
Intent.createChooser(i, "Image Browser"),
FILECHOOSER_RESULTCODE);
}
});
但是 openFileChooser 永远不会被调用.有任何想法吗?openFileChooser 在 Android 源代码中被标记为 @hide.我认为这是因为你不应该使用这种方法.还有另一种可能打开文件选择器吗??
but openFileChooser is never called. Any ideas? openFileChooser is marked @hide in Android source code. I think its because you should NOT use this method. Is there another possibility to open a fileChooser??
推荐答案
openFileChooser 的参数已经更新了一些时间.
Parameters for openFileChooser have been updated some times.
对于 Android 3.0 - 4.0,它是
For Android 3.0 - 4.0, it is
public void openFileChooser( ValueCallback<Uri> uploadMsg, String acceptType )
对于 4.1,
public void openFileChooser(ValueCallback<Uri> uploadMsg, String acceptType, String capture)
对于 2.x
public void openFileChooser( ValueCallback<Uri> uploadMsg )
您必须添加所有这些以支持 Android 2.0 和 4.1 之间的任何设备.
You'll have to add all of them to support any devices between Android 2.0 and 4.1.
这篇关于WebView Android 4.0 文件上传的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文