3

In my application I just want to listen to the picture captured by user in camera and increase the photo count.I tried listen to

<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 intents .But these intents are not working for galaxy. Is there any other method to listen to the captured images.

thej
  • 648
  • 10
  • 33

3 Answers3

1

Look here

The clue is to launch the activity with the intent pased as parameter:

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

And capture 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
        }
    }
}
Community
  • 1
  • 1
gutiory
  • 1,135
  • 5
  • 13
  • 33
  • But I just want listen to photo taken in default camera by user and increase count. – thej May 04 '12 at 05:51
  • 1
    In fact, this method launch the default camera. You just need to increase your count inside onActivityResult. – gutiory May 04 '12 at 05:58
  • 1
    but its launching new camera but what i want is user take picture using camera in his device. my application should keep track of how many photos captured by the user – thej May 04 '12 at 06:31
1

I think you should use picture 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 your camera and every time when you take picture control will come in above function.

you can set your picture callback to

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..

if you want to use default camera then you can use it.

Camera mCamera = Camera.open();

BenMorel
  • 34,448
  • 50
  • 182
  • 322
Bharat Sharma
  • 3,926
  • 2
  • 17
  • 29
  • I don't have any camera object and i want to use default camera in device and increase the count by one every time i take picture. – thej May 04 '12 at 06:15
  • user take picture using camera in his device. my application should keep track of how many photos captured by the user – thej May 04 '12 at 06:21
0

I know, this thread is quite old and unanswered, but I was also searching for the same solution. And found some useful hints here on Stackoverflow and a post by Vogella here.

Just in case anyone needs something similar...

Community
  • 1
  • 1
casaout
  • 1,819
  • 3
  • 24
  • 54