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

2010-05-28 Thread Sicz-Mesziár János
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+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


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

2010-02-18 Thread Streets Of Boston
This is the stack trace:

Android OS: 1.5
Model: HERO200
Make: heroc:sprint

Caused by: java.io.IOException: autoFocus failed
at android.hardware.Camera.native_autoFocus(Native Method)
at android.hardware.Camera.autoFocus(Camera.java:313)
at com.streetsofboston.smugdroid.snapfx.camera.SmugCamera
$Preview.autoFocus(SmugCamera.java:1492)


This exception is not documented. The JavaDoc of Camea.autoFocus does
not mention this exception at all.
How can i prevent this from happening or can i just catch it and
continue to instruct the camera to take a picture.

Thanks!

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