How to listen to the image captured by the camera in android

In my application, I just want to listen to the picture taken by the user and increase the number of photos. I tried to listen

<action android:name="android.provider.MediaStore.ACTION_IMAGE_CAPTURE" />
<action android:name="android.media.action.IMAGE_CAPTURE" />
<action android:name="android.media.action.STILL_IMAGE_CAMERA" />
<action android:name="android.intent.action.CAMERA_BUTTON" />

above intentions. But these intentions do not work for the galaxy. Is there any other way to listen to captured images.

+3
source share
3 answers

Look here

The hint is to start the action with the intent specified as a parameter:

Intent intent = new Intent("android.media.action.IMAGE_CAPTURE");
startActivityForResult(intent, TAKE_PICTURE);

And write down the result of the activity:

@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);
    switch (requestCode) {
    case TAKE_PICTURE:
        if (resultCode == Activity.RESULT_OK) {
            // Do something
        }
    }
}
+1
source

I think you should use image callback

                    Camera.PictureCallback picture_callback = new Camera.PictureCallback() {

                        @Override
                        public void onPictureTaken(byte[] data, Camera camera) {
                            // WRITE YOUR CODE WHEN PICTURE TAKEN.
                            // "data" IS YOUR TAKEN PICTURE FRAME. 
                        }
                    };

set picture_callback to the camera, and each time you perform image management, you will be taken to the above function.

if you have raw frame
        mCamera.takePicture(null, picture_callback, null);

if you have jpeg frame
        mCamera.takePicture(null, null, picture_callback);

hope it will help you..

, .

mCamera = Camera.open();

+1

I know this topic is quite old and unanswered, but I was also looking for the same solution. And I found useful useful tips fooobar.com/questions/1907105 / ... and a post from Vogella here .

Just in case, someone needs something like that ...

0
source

All Articles