gpt4 book ai didi

Android webview,文件上传,在onActivityResult中设置结果时崩溃

转载 作者:塔克拉玛干 更新时间:2023-11-02 08:58:17 26 4
gpt4 key购买 nike

在 Android webview 中,当文件上传选项被点击时,onShowFileChooser 被调用,用户从图片库中选择要上传的文件的 Intent 被调用。选择文件后,在 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)

最佳答案

@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;
}

返回真值

关于Android webview,文件上传,在onActivityResult中设置结果时崩溃,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37563215/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com