I am getting Intent data = null
and i don't understand why? i am using an
intent from an Activity B
(A to B: using an intent too (startActivity())
) like this:
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 myonActivityResult
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 am saving the picture here: File storageDirec = this.getExternalFilesDir(Environment.DIRECTORY_PICTURES);
. From debug i am getting correct params(requestCode = 1 & resultCode = -1
), but data = null
? - Can somebody tell/help me why the Intent data is null? - Thanks, Carl