Roughly:

Camera mCamera = Camera.open();

// this sequence should occur after onResume and surfaceCreated
mCamera.setPreviewDisplay(mSurfaceHolder); // saved from
surfaceCreated call
mCamera.startPreview();

// to start focus - usally called from your onClickListener
mCamera.autoFocus(afCallback);

// to take picture - usually called from your onClick listener
mCamera.takePicture(shutterCallback, null, pictureCallback);

// auto focus callback
public void autoFocusCallback(boolean focused, Camera camera) {
    // play focused sound
}

// shutter callback function
public void shutterCallback() {
    // play shutter sound
}

// picture callback function
public void pictureCallback(byte rawData[], Camera camera) {
    // save JPEG
}

You should also note that there is significant lag from the time
takePicture() is called until the image capture begins. You can
shorten this time by calling auto-focus first. You don't want to move
the camera until after the shutter callback.

On Jan 21, 1:59 am, "mobilek...@googlemail.com"
<mobilek...@googlemail.com> wrote:
> Could you list the proper sequence as I'm having hard time working it
> out! Thanks
>
> On Jan 21, 3:21 am, Dave Sparks <davidspa...@android.com> wrote:
>
> > Sounds like you might have some sequencing issues. Did you call
> > startPreview first?
>
> > On Jan 20, 2:51 pm, "mobilek...@googlemail.com"
>
> > <mobilek...@googlemail.com> wrote:
> > > Hi, thanks for the hint! I've tried that but I got this:
>
> > > java.io.IOException: autoFocus failed
>
> > > I registered the callback in CameraActivity.surfaceCreated() method.
>
> > > Could you advice on how to get that working? Thank you!
>
> > > On Jan 20, 5:09 pm, Dave Sparks <davidspa...@android.com> wrote:
>
> > > > Camera.autoFocus(cb);
>
> > > > where cb is a callback function you supply that tells you focus is
> > > > successful or not.
>
> > > > On Jan 20, 5:27 am, "mobilek...@googlemail.com"
>
> > > > <mobilek...@googlemail.com> wrote:
> > > > > Hi,
>
> > > > > My app is struggling to take focused shots. Is there a built in
> > > > > facility that sets an auto-focus property on the camera, so it
> > > > > automatically takes clear and focused images. I've noticed that
> > > > > feature in numerous well-known apps such as ShopSavvy,
> > > > > CompareEverywhere, etc.
>
> > > > > Could you advise on how to achieve that?
>
> > > > > Thank you.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers-unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to