Justson / AgentWeb

AgentWeb is a powerful library based on Android WebView.
https://www.jianshu.com/p/fc7909e24178
Apache License 2.0
9.27k stars 1.64k forks source link

拍照和文件选择问题 #1029

Closed jpchenghub closed 1 year ago

jpchenghub commented 1 year ago

您好, 问下AgentWeb最新版本支持拍照和选择文件默认只是拍照或者选择文件,现在好像默认是让用户选择相机或文件,但是我的需求是只需要拍照不需要暴露文件选项!

lx1549181884 commented 1 year ago
    mAgentWeb = AgentWeb.with(this)
            .setAgentWebParent()
            .useDefaultIndicator()
            .setAgentWebUIController(new AgentWebUIControllerImplBase(){
                @Override
                public void onSelectItemsPrompt(WebView view, String url, String[] ways, Handler.Callback callback) {
                    // 拦截拍照和选择文件,自定义代码可参考 super.onSelectItemsPrompt
                }
            })
            .createAgentWeb()
            .go(getUrl());
LXLYHM commented 11 months ago

.setAgentWebUIController(object : AgentWebUIControllerImplBase() { override fun onSelectItemsPrompt(view: WebView, url: String, ways: Array, callback: Handler.Callback) { // 拦截拍照和选择文件,只需要拍照 if (callback != null) { val mMessage = Message.obtain() mMessage.what = 0 //mMessage.what 必须等于ways的index callback.handleMessage(mMessage) //最后callback一定要回调 } } }) 只让用户跳转相册,但是还是会弹出读取文件的权限怎么解决?