149/5000
当我使用webview通过重写onShowFileChooser来获取Android手机相册的图片时,不需要在6.0以上的手机上申请存储权限,并且可以直接获取图片而没有任何错误。我想知道,您是否不必须申请存储权才能从Android6.0上的相册中获取照片?
不申请许可不会报告错误,可以正常运行
测试机:三星(8.0),乐视(6.0)
//4.1<=android<=4.4
@Override
public void openFileChooser(ValueCallback<Uri> valueCallback, String s, String s1) {
mUploadMessage = valueCallback;
Intent i = new Intent(Intent.ACTION_GET_CONTENT);
i.addCategory(Intent.CATEGORY_OPENABLE);
i.setType("image/*");
activity.startActivityForResult(Intent.createChooser(i, "File Chooser"), FILE_CHOOSE_NUM);
}
//android >=5.0
@Override
public boolean onShowFileChooser(WebView webView, ValueCallback<Uri[]> valueCallback, FileChooserParams fileChooserParams) {
mUploadMessageHigh = valueCallback;
Intent contentSelectionIntent = new Intent(Intent.ACTION_GET_CONTENT);
contentSelectionIntent.addCategory(Intent.CATEGORY_OPENABLE);
contentSelectionIntent.setType("image/*");
Intent chooserIntent = new Intent(Intent.ACTION_CHOOSER);
chooserIntent.putExtra(Intent.EXTRA_INTENT, contentSelectionIntent);
chooserIntent.putExtra(Intent.EXTRA_TITLE, "Image Chooser");
activity.startActivityForResult(chooserIntent, IMAGE_CHOOSE_NUM);
return true /*super.onShowFileChooser(webView, valueCallback, fileChooserParams)*/;
}