Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

大佬,怎样在 webview 里面 js 调用它? #34

Open
y2891663091 opened this issue Apr 6, 2020 · 2 comments
Open

大佬,怎样在 webview 里面 js 调用它? #34

y2891663091 opened this issue Apr 6, 2020 · 2 comments

Comments

@y2891663091
Copy link

我是做前端的,不太懂java,,想在webview 调用它?请问怎么实现

@lbrjms
Copy link

lbrjms commented Aug 5, 2020

我是通过图片路径生成uri对象数组 然后回传给h5的
// 图片选择或者拍照之后的会回调

  if (requestCode == WebviewGlobals.CHOOSE_IMAGES_REQUEST_CODE && resultCode == RESULT_OK) {
                // 拿到选中图片路径
                mImagePaths = data.getStringArrayListExtra(ImagePicker.EXTRA_SELECT_IMAGES);
                // 初始化Uri数组
                Uri[] results = new Uri[mImagePaths.size()];
                // 通过路径生成Uri对象保存在数组中
                for (int i = 0; i < mImagePaths.size(); i++) {
                    results[i] = Uri.parse(mImagePaths.get(i));
                }
                // 传给h5的input标签
                mX5WebView.getX5WebChromeClient().getmUploadCallbackAboveL().onReceiveValue(results);//将文件路径返回去,填充到input中
                mX5WebView.getX5WebChromeClient().setmUploadCallbackAboveL(null);
            }

@lbrjms
Copy link

lbrjms commented Aug 11, 2020

你搜索 webview 与原生交互就行了 就是两边定义一个相同的方法 很简单的

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants