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

Yas*_*tel 7 javascript android

我有一个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, "");
        }
Run Code Online (Sandbox Code Playgroud)

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

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

Yas*_*tel 4

4.3 之后没有任何方法可以使用openFileChooser方法,因为 google 已删除该方法,并且他们将在下一个版本中提出其他方法来处理此文件选择器内容(由 Google 工程师确认)。

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