我有一个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方法,因为谷歌已经删除了它,他们会在下一个版本中提出处理这个文件选择器的其他方法(由谷歌工程师确认).
我转向混合架构并为文件选择器编写本机函数.