What data is returned when using ACTION_IMAGE_CAPTURE?
I’m a little confused about this description :
The caller may pass an extra EXTRA_OUTPUT to control where this image
will be written. If the EXTRA_OUTPUT is not present, then a small
sized image is returned as a Bitmap object in the extra field. This is
useful for applications that only need a small image. If the
EXTRA_OUTPUT is present, then the full-sized image will be written to
the Uri value of EXTRA_OUTPUT.
If there is no EXTRA_OUTPUT
, does it return a “small size image”?
With EXTRA_OUTPUT
, does it return a full-size image?
“Returned as a bitmap object in an extra field”….
On my onActivityResult
, I just use Intent data as the actual data
. Should I use data.getExtra
or what?
Solution
If you provide a URI:
Intent action = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
action.putExtra(android.provider.MediaStore.EXTRA_OUTPUT, myUri);
startActivityForResult(action, CAMERA_RESULT);
Then you retrieve it using (after testing requestCode and resultCode:).
Bitmap bitmap = BitmapFactory.decodeFile(myUri, options);
Another scenario:
Intent intent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
startActivityForResult(intent, CAMERA_RESULT);
Then retrieve it as follows:
Bundle bundle = intent.getExtras();
Bitmap bitmap = (Bitmap) extras.get("data");