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

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

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

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

public void openFileChooser(ValueCallback<Uri> 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<Uri> uploadMsg){
            openFileChooser(uploadMsg,"");
        }
        //Aftre
        public void openFileChooser(ValueCallback<Uri> uploadMsg,String acceptType,String capture) {
            openFileChooser(uploadMsg,"");
        }

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

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

解决方法

4.3之后没有办法打开OpenCileChooser方法,因为谷歌已经删除了它,他们会在下一个版本中提出处理这个文件选择器的其他方法(由谷歌工程师确认).

我转向混合架构并为文件选择器编写本机函数.

相关文章

前言 做过web项目开发的人对layer弹层组件肯定不陌生,作为l...
前言 前端表单校验是过滤无效数据、假数据、有毒数据的第一步...
前言 图片上传是web项目常见的需求,我基于之前的博客的代码...
前言 导出Excel文件这个功能,通常都是在后端实现返回前端一...
前言 众所周知,js是单线程的,从上往下,从左往右依次执行,...
前言 项目开发中,我们可能会碰到这样的需求:select标签,禁...