Friday, May 28, 2010

[android-developers] Camera on HTC Hero: Calling camera.autoFocus(...) gives a IOException .. ?

Hi guys!

I also was a problem on my Hero.
But I found a solution.

05-28 21:58:58.058: ERROR/QualcommCameraHardware(37): Invalid camera
state QCS_IDLE: expecting QCS_PREVIEW_IN_PROGRESS, cannot start
autofocus!
05-28 21:58:58.059: DEBUG/CAM OPEN(2710): java.io.IOException:
autoFocus failed

From state machine follows the solution:
1.) Start the Preview.
2.) After set the autoFocus.

Example:
@Override
public void surfaceChanged(SurfaceHolder holder, int format, int
width, int height) {
if(started) cam.stopPreview();
Camera.Parameters params = cam.getParameters();
params.setPictureSize(width, height);
params.setPreviewSize(width, height);
cam.setParameters(params);
cam.startPreview();
cam.autoFocus(this);
started = true;
}

@Override
public void onAutoFocus(boolean success, Camera camera) {
/* .... */
}

I hope someone helps.

--
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+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate