我可以使用一些帮助。这是我的第一个Android项目。我想用相机拍照,然后在ImageView中显示它。我可以拍照并将其保存在SD卡上的文件夹中(文件路径始终相同),但我无法在ImageView中显示它。 (文件是存在的,因为我使用的是相同的路径email.intent超过电子邮件客户端发送和它的作品。)如何使用BitmapFactory在ImageView中显示SD卡中的JPG文件 - Android Studio
代码用于显示图像:
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
final File imgFile = new File("/storage/emulated/0/camera_app/cam_image.jpg");
if(imgFile.exists()){
Bitmap myBitmap = BitmapFactory.decodeFile(imgFile.getAbsolutePath());
ImageView kamera3= (ImageView) findViewById(R.id.kamera2);
kamera3.setImageBitmap(myBitmap);
}
我也试过:
Bitmap myBitmap = BitmapFactory.decodeFile("/storage/emulated/0/camera_app/cam_image.jpg");
ImageView kamera3= (ImageView) findViewById(R.id.kamera2);
kamera3.setImageBitmap(myBitmap);
你检查运行许可? –
粘贴您的完整代码,因为您没有在上面的onActivityResult方法中检查requestCode和resultCode。 –
添加权限清单文件'<使用权限android:name =“android.permission.WRITE_EXTERNAL_STORAGE”/>' –