gpt4 book ai didi

Android webview onShowFileChooser onReceiveValue没有效果

转载 作者:行者123 更新时间:2023-11-29 16:34:34 24 4
gpt4 key购买 nike

public class MyWebViewChromeClient extends WebChromeClient {
private ValueCallback<Uri> uploadMessage;
private ValueCallback<Uri[]> uploadMessageAboveL;

// For Android >= 5.0
@Override
public boolean onShowFileChooser(WebView webView, ValueCallback<Uri[]> filePathCallback, WebChromeClient.FileChooserParams fileChooserParams) {

File file = new File("storage/emulated/0/Android/data/com.mycompanydomain.proejectname/files/Pictures/JPEG_21652498916216.jpg");
if (file.exists()) {
Log.e("BBBBBBBB","fileexists");
} else {
Log.e("BBBBBBBB","filenotexists");
}

filePathCallback.onReceiveValue(new Uri[]{Uri.parse("storage/emulated/0/Android/data/com.mycompanydomain.proejectname/files/Pictures/JPEG_21652498916216.jpg")});
return true;
}
}

我正在尝试在 webview 中处理文件上传。我能够获取文件上传请求,然后我使用 Intent 拍摄照片并将其成功保存到路径。不过,似乎

filePathCallback.onReceiveValue(new Uri[]{Uri.parse("storage/emulated/0/Android/data/com.mycompanydomain.proejectname/files/Pictures/JPEG_21652498916216.jpg")});

不起作用,因为 webview 没有收到图像并且没有任何反应。

显示文件确实存在,但是webview没有任何响应,上面的代码根本没有任何效果。我无法弄清楚代码有什么问题,有人可以帮助我吗?非常感谢。

最佳答案

我终于自己解决了问题。

  File f=new File("path to file");
Uri u=Uri.fromFile(f);
filePathCallback.onReceiveValue(new Uri[]{u});

上面的代码对我有用。

关于Android webview onShowFileChooser onReceiveValue没有效果,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52835354/

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