Why is Intent onActivityResult () data null?
I receive Intent data = null
and I don't understand why? i use with Activity B
( A to B: using an intent too (startActivity())
):
Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
if (intent.resolveActivity(getPackageManager()) != null) {
File image = null;
try {
image = saveImageFile();
} catch (IOException ex) {
Toast.makeText(this, ex.getMessage(),Toast.LENGTH_LONG).show();
}
if (image != null) {
intent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(image ));
startActivityForResult(intent, REQUEST_TAKE_PHOTO);
}
} else {
Toast.makeText(this, "Cannot take a picture!", Toast.LENGTH_LONG).show();
}
and from mine onActivityResult
I tried this:
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
if (requestCode == REQUEST_TAKE_PHOTO && resultCode == RESULT_OK) {
Bundle extras = getIntent().getExtras();
if (extras == null) {
return;
}
Bitmap myImageBitmap = (Bitmap) extras.get("data");
scaleMyImage(myImageBitmap);
} else if(resultCode == RESULT_CANCELED) {
finish();
}
}
I save the images here: File storageDirec = this.getExternalFilesDir(Environment.DIRECTORY_PICTURES);
. From debug I am getting the correct parameters ( requestCode = 1 & resultCode = -1
), but data = null
? - Can anyone tell / help me why the Intent data is null? - Thank you, Karl
source to share
No one has answered this question yet
See similar questions:
or similar: