对于文件选择器openFileChooser()方法,不调用Kitkat 4.4的WebChromeClient

 wugege36 发布于 2023-02-07 12:58

我有一个hi-bride应用程序,其中一个html页面有文件选择器,我想在Android webview中加载该页面.

此选择器在设备浏览器中运行良好,但在webview中不适用.

为了支持这个,我使用WebChromeClient的一个隐藏方法,如下所示

public void openFileChooser(ValueCallback uploadMsg, String acceptType){  
            /**updated, out of the IF **/
            mUploadMessage = uploadMsg;
            /**updated, out of the IF **/
            if(boolFileChooser){ //Take picture from filechooser
                Intent i = new Intent(Intent.ACTION_GET_CONTENT);  
                i.addCategory(Intent.CATEGORY_OPENABLE);  
                i.setType("image/*");  
                startActivityForResult( Intent.createChooser( i, "Pick File.." ), FILECHOOSER_RESULTCODE );  
            } else { //Take photo and upload picture
                Intent cameraIntent = new Intent("android.media.action.IMAGE_CAPTURE");
                photo = new File(Environment.getExternalStorageDirectory(),  "Pic.jpg");
                if(photo.exists())
                    photo.delete();
                cameraIntent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(photo));
                mCapturedImageURI = Uri.fromFile(photo);
                startActivityForResult(cameraIntent, CAMERAREQUEST_RESULTCODE);
            }
        }
    // Per Android < 3.0
        public void openFileChooser(ValueCallback uploadMsg){
            openFileChooser(uploadMsg, "");
        }
        //Aftre
        public void openFileChooser(ValueCallback uploadMsg, String acceptType, String capture) {
            openFileChooser(uploadMsg, "");
        }

它工作正常,直到4.3,但从4.4开始,这种方法没有被调用.他们说https://code.google.com/p/android/issues/detail?id=62220已被删除.

有谁知道任何替代方式.请让我知道你的帮助将不胜感激

撰写答案
今天,你开发时遇到什么问题呢?
立即提问
热门标签
PHP1.CN | 中国最专业的PHP中文社区 | PNG素材下载 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有