webview中的多个选定文件显示未选择任何文件

时间:2017-09-26 13:37:28

标签: java android webview

我想在webview中上传多个图片,我可以选择多个文件但是当我选择文件并点击打开网页时输入显示没有文件。

     @Override
    protected void onActivityResult(int requestCode, int resultCode, Intent intent){
super.onActivityResult(requestCode, resultCode, intent);
if(Build.VERSION.SDK_INT >= 21){
    Uri[] results = null;
    //Check if response is positive
    if(resultCode== Activity.RESULT_OK){
        if(requestCode == FCR){
            if(null == mUMA){
                return;
            }
            if(intent == null){
                //Capture Photo if no image available
                if(mCM != null){
                    results = new Uri[]{Uri.parse(mCM)};
                }
            }else{
                String dataString = intent.getDataString();
                if(dataString != null){
                    results = new Uri[]{Uri.parse(dataString)};
                }
            }
        }
    }
    mUMA.onReceiveValue(results);
    mUMA = null;
}else{
    if(requestCode == FCR){
        if(null == mUM) return;
        Uri result = intent == null || resultCode != RESULT_OK ? null : intent.getData();
        mUM.onReceiveValue(result);
        mUM = null;
    }
}

}

我的onShowFileChooser代码是

   @TargetApi(Build.VERSION_CODES.LOLLIPOP)
            public boolean onShowFileChooser(
                    WebView webView, ValueCallback<Uri[]> filePathCallback,
                    WebChromeClient.FileChooserParams fileChooserParams){
                if(mUMA != null){
                    mUMA.onReceiveValue(null);
                }
                mUMA = filePathCallback;

                Intent contentSelectionIntent = new Intent(Intent.ACTION_GET_CONTENT);
                contentSelectionIntent.addCategory(Intent.CATEGORY_OPENABLE);
                contentSelectionIntent.setType("*/*");
                contentSelectionIntent.putExtra(Intent.EXTRA_ALLOW_MULTIPLE, true);

                Intent chooserIntent = new Intent(Intent.ACTION_CHOOSER);
                chooserIntent.putExtra(Intent.EXTRA_INTENT, contentSelectionIntent);
                chooserIntent.putExtra(Intent.EXTRA_TITLE, "Image Chooser");
                startActivityForResult(chooserIntent, FCR);
                return true;
            }

我在互联网上搜索但找不到合适的答案。

0 个答案:

没有答案