我有一個關於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