I am making an Android app that can take a picture and save it to the gallery. However, after taking the picture and tapping on the checkmark, the camera intent dismisses but the app is closed and the picture is not saved.
Intent cameraIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
File pictureDirectory = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES);
String imageName = "Blah.jpg";
File imageFile = new File(pictureDirectory, imageName);
Uri pictureUri = Uri.fromFile(imageFile);
cameraIntent.putExtra(MediaStore.EXTRA_OUTPUT, pictureUri);
startActivityForResult(cameraIntent,1313);
The intent successfully launches but the following is never called and the app just closes:
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
if (requestCode == 1313 && resultCode == RESULT_OK) {
//...
}
}