O arquivo da foto não esta sendo encontrado. Não consegui achar o problema no código. Meu emulador esta com Android 6.
03-26 16:09:45.615 8011-8011/com.paris.agenda E/BitmapFactory: Unable to decode stream: java.io.FileNotFoundException: /storage/emulated/0/Android/data/com.paris.agenda/files/1553616574068.jpg: open failed: ENOENT (No such file or directory)
public class FormActivity extends AppCompatActivity {
public static final int REQUEST_CODE_IMAGE_CAMERA = 111;
private FormData data;
private String localSavePhoto;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_fomr);
this.data = new FormData(this);
final Intent intent = getIntent();
Student student = (Student) intent.getSerializableExtra("student");
if (student != null) {
data.fillOutForm(student);
}
Button buttonCamera = findViewById(R.id.form_button_camera);
buttonCamera.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intentCamera = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
localSavePhoto = getExternalFilesDir(null) + "/" + System.currentTimeMillis() + ".jpg";
File filePhoto = new File(localSavePhoto);
intent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(filePhoto));
startActivityForResult(intentCamera, REQUEST_CODE_IMAGE_CAMERA);
}
});
}
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if (resultCode == Activity.RESULT_OK && requestCode == REQUEST_CODE_IMAGE_CAMERA) {
if (localSavePhoto != null) {
Bitmap bitmap = BitmapFactory.decodeFile(localSavePhoto);
if (bitmap != null) {
Bitmap bitmapReduced = Bitmap.createScaledBitmap(bitmap, 100, 100, true);
ImageView photo = findViewById(R.id.form_image);
photo.setImageBitmap(bitmapReduced);
photo.setScaleType(ImageView.ScaleType.FIT_XY);
}
}
}
}