我有一个关于BitMapFactory.decodeFile的问题。BitmapFactory:无法解码流:java.io.FileNotFoundException
在我的应用程序中,我希望用户能够从他/她的设备中选择图像或拍摄照片。这必须然后显示在一个ImageView的
下面是代码片段:
Uri selectedImage = data.getData();
String[] filePathColumn = {MediaStore.Images.Media.DATA};
Cursor cursor = getContentResolver().query(selectedImage, filePathColumn, null, null, null);
cursor.moveToFirst();
int columnIndex = cursor.getColumnIndex(filePathColumn[0]);
String picturePath = cursor.getString(columnIndex);
cursor.close();
MyImage image = new MyImage();
image.setTitle("Test");
image.setDescription("test choose a photo from gallery and add it to " + "list view");
image.setDatetime(System.currentTimeMillis());
image.setPath(picturePath);
而且我得到这个异常:
BitmapFactory: Unable to decode stream: java.io.FileNotFoundException: /storage/emulated/0/WhatsApp/Media/WhatsApp Images/IMG-20170302-WA0012.jpg: open failed: EACCES (Permission denied)
如何解决it.Please帮助me.Thanks提前..
这是EasyPermissions,如果它是类或字段? – Monali
它的库编译'pub.devrel:easypermissions:0.2.1' –
非常感谢..你节省了我的一天.. – Monali