在Android webview中,单击文件上载选项时,将调用onShowFileChooser,以调用用户从图像库中选择要上载的文件的意图。 选择文件后,在onActivityResult内部由于以下原因而崩溃
java.lang.IllegalStateException: Duplicate showFileChooser result
at org.chromium.android_webview.AwWebContentsDelegateAdapter$2.onReceiveValue(AwWebContentsDelegateAdapter.java:225)
at org.chromium.android_webview.AwWebContentsDelegateAdapter$2.onReceiveValue(AwWebContentsDelegateAdapter.java:220)
at com.android.webview.chromium.WebViewContentsClientAdapter$4.onReceiveValue(WebViewContentsClientAdapter.java:1063)
at com.android.webview.chromium.WebViewContentsClientAdapter$4.onReceiveValue(WebViewContentsClientAdapter.java:1047)
答案 0 :(得分:12)
@Override
public boolean onShowFileChooser(WebView webView, ValueCallback<Uri[]> filePathCallback, FileChooserParams fileChooserParams) {
mActivity.setValueCallback(filePathCallback);
Intent intent = new Intent(Intent.ACTION_GET_CONTENT);
intent.addCategory(Intent.CATEGORY_OPENABLE);
intent.setType("*/*");
mActivity.startActivityForResult(Intent.createChooser(intent, ""), Final.REQUEST_CODE_ALBUM);
return true;
}
返回true
答案 1 :(得分:2)
如果您覆盖onShowFileChooser
并计划调用filePathCallback
来传递结果,则必须从onShowFileChooser
返回true,告知基础代码不要将值传递给filePathCallback
真实的基本上是说“我会处理它”
文档:
@return true if filePathCallback will be invoked, false to use default handling.
答案 2 :(得分:0)
我认为您需要实现webview并扩展webview chrome客户端以处理Android手机应用程序上的文件上传。您可以阅读这些article可能有助于您了解如何实现webview客户端类和webchrome客户端
答案 3 :(得分:0)
可能是因为你将在uri中获取数据然后制作uri数组的新对象。在C#中,我在下面做了解决问题: 代码是givinf重复错误:
Android.Net.Uri[] result = data == null || resultCode != Result.Ok ? null : new Android.Net.Uri[] { data.Data };
以下代码解决了问题:
Cumulative:=CALCULATE(
SUM( Shifts[Score] ) ,
FILTER(Shifts,Shifts[Cumulative Days] <= VALUES(Shifts[Cumulative Days] )) ,
ALLEXCEPT( shifts, Shifts[Workday],Shifts[EMP_ID] ) )