我想从imageView中的存储打开图像,我有这个错误:
无法解码流:java.io.FileNotFoundException:/storage/1A10-2F0F/Pictures/photo.jpg:open failed:EACCES(Permission denied)
如何在imageView中打开图片?
我的代码:
ImageView img;
@Override
public void onActivityResult(int requestCode, int resultCode, Intent intent) {
Bitmap bitmap = BitmapFactory.decodeFile(imageFile.getAbsolutePath());
img.setImageBitmap(bitmap);
}
OneClick按钮打开ImageCapture:
@Override
public void onClick(View view) {
Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
imageFile = new File(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES), "photo.jpg");
Uri photoPath = Uri.fromFile(imageFile);
intent.putExtra(MediaStore.EXTRA_OUTPUT, photoPath);
startActivityForResult(intent, TAKE_PICTURE);
}
OnCreate中:
...
img = (ImageView) findViewById(R.id.imageView);
...
我在AndroidMainfest中添加了:
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />`
提前致谢。