ked*_*ked 8 android webview webchromeclient
在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)
Run Code Online (Sandbox Code Playgroud)
小智 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;
}
Run Code Online (Sandbox Code Playgroud)
返回true
如果您重写onShowFileChooser并计划调用来filePathCallback传递结果,则必须返回 true,从而onShowFileChooser告诉底层代码不要将值传递给filePathCallback.
真正的基本上是说“我会处理它”
文档:
@return true if filePathCallback will be invoked, false to use default handling.
| 归档时间: |
|
| 查看次数: |
3457 次 |
| 最近记录: |