我正在使用具有api 27(oreo)的手机。我想从sdcard / picture文件夹发送图像。但是我遇到了错误::
原因:android.os.FileUriExposedException: 文件:///storage/emulated/0/Pictures/_20181117_115002.jpg暴露 通过ClipData.Item.getUri()超越应用程序
我的代码如下所示。
File pictures = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES);
String[] listofpictures = pictures.list();
Log.e("images::", String.valueOf(listofpictures.length));
Uri uri = null;
ArrayList<Uri> arrayList = new ArrayList<Uri>();
for (String picture : listofpictures) {
uri = Uri.parse("file://" + pictures.toString() + "/" + picture);
arrayList.add(uri);
}
intent = new Intent(Intent.ACTION_SEND_MULTIPLE);
intent.setType("image/*");
intent.putExtra(Intent.EXTRA_STREAM, arrayList);
chooser = Intent.createChooser(intent, "send multiple images");
startActivity(intent);