I have an Android application which uses a intent. here is the code:
private static final int CAPTURE_IMAGE= 1;
[...]
Uri imageUri = helper.createImageDestinationUri(null, filename);
[...]
Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
intent.putExtra(MediaStore.EXTRA_OUTPUT, imageUri);
startActivityForResult(intent, CAPTURE_IMAGE);
and then I get the result here:
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
if (requestCode == CAPTURE_IMAGE) {
if (requestCode == Activity.RESULT_OK) {
Toast.makeText(this, "Image saved to:\n" +
data.getData(), Toast.LENGTH_LONG).show();
}
else {
Toast.makeText(getApplicationContext(), "Error", Toast.LENGTH_SHORT).show();
}
}
}
I have all the permissions which are needed.
the strange thing:
at the end the picture is always on my SD card but I never get the RESULT_OK result.
what is wrong there?
You’re checking requestCode for RESULT_OK
when you should be checking resultCode