I am trying to get the image from the camera. It works fine. I can take a photo and show it on the image view. Actually, I want to send this photo to my server after took. To do that, I try to pull the image in onActivityResult. But, when i check the Intent data, it always return null.Even though, the application runs fine and display the image. Why am I getting null for Intent data? Could you please help me?
Here is the code:
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
switch (requestCode) {
case ACTION_TAKE_PHOTO_B: {
if (resultCode == RESULT_OK) {
Log.e("TAG","data: "+data);
display_Photo();
//Process the image to send but, data is null
}
break;
}
}
}
Log cat:
data : Null
In the code you are using there are two button onclick handlers that call:
dispatchTakePictureIntent(int actionCode)One button calls it with the enum
ACTION_TAKE_PHOTO_Bwhile the other call sit with the enumACTION_TAKE_PHOTO_SIf you are passing in
ACTION_TAKE_PHOTO_B, then the expected result ofdatain the returned intent isnull.The reason why is that before
dispatchTakePictureIntentcalls the intentMediaStore.ACTION_IMAGE_CAPTURE, it sets an extra intent parameter based on theactionCodepassed in:According to the documentation for ACTION_IMAGE_CAPTURE:
So, because the
EXTRA_OUTPUTparameter is being set, your image is being written to disk instead of being returned as data in the intent. To get the file location, you can inspectmCurrentPhotoPathwhich is written to before the intent is launched.