I want to display an image taken from the camera in an ImageView using
Intent intent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
This works fine so far but after the user takes the photo using the chosen camera app a dialog (probably from the app) appears asking whether to save or delete the taken picture (at least on Android 2.3 and 4.2 using the default camera app).
I would like to skip this extra dialog and directly display the image in the ImageView (when onActivityResult gets called), because it means an extra interaction step for the user, which is unneccessary because he will have the possibilty to save or delete the photo in my app.
Is this possible using the simple ACTION_IMAGE_CAPTURE Intent or will I need something more complex like Camera Preview and SurfaceView for this purpose ?
Use "android.intent.extra.quickCapture"
You can not do it using the default intent. You will have to write a customer camera capture functionality where you can skip the preview with Ok and Cancel buttons.
Pleas see http://developer.android.com/guide/topics/media/camera.html#custom-camera
You can use the solution of AnujMathur_07, but if you do not want work with paths and files, in the method
onPictureTaken
, you can return the bitmap:And in the method
onActivityResult
you can get bitmap:You ca use the
SurfaceView
to capture imageAnd the layout file would be
Start this
Camera_capture
activity withstartActivityForResult
andonActivityResult
you can get the image asbyte
array aswhere
data
is the received data.Decode the
byte
array toBitmap
usingnow set this
Bitmap
Edit
As there is some problem while returning
byte[]
, thebyte[]
should be save in a file and the path of the file should be sent to the previousActivity
so that file can be read.In
onPictureTaken()
, just addand in place of :
write
and receive this path in previous
Activity
'sonActivityResult
as :Use MediaStore.EXTRA_OUTPUT param for you camera application running intent
If your image is rotated, you can use this:
after