KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
I have tried everything but I'm still unable to solve this issue. I am implementing a camera feature in an app and everything works fine except the autofocus. When I call autoFocus(), it throws an exception, and I can't understand why. I am running the code on a Desire HD. Code: @Override protected void onStart() { super.onStart(); //grab seurface view and callback cameraView = (CameraSurfaceView) findViewById(R.id.cameraView); try{ camera = Camera.open(); cameraView.setCamera(camera); //release previous autofocus and assign new one camera.cancelAutoFocus(); camera.autoFocus(new Camera.AutoFocusCallback() { public void onAutoFocus(boolean success, Camera camera) { // TODO Auto-generated method stub }}); } catch (Exception e) { //had an issue accessing the camera prompt user //TODO create user prompt e.printStackTrace(); } } Stack trace: 01-11 16:09:38.456: W/System.err(26546): java.lang.RuntimeException: autoFocus failed 01-11 16:09:38.456: W/System.err(26546): at android.hardware.Camera.native_autoFocus(Native Method) 01-11 16:09:38.456: W/System.err(26546): at android.hardware.Camera.autoFocus(Camera.java:680) 01-11 16:09:38.456: W/System.err(26546): at com.myapp.MyActivity.onStart(BarcodeScannerActivity.java:57) 01-11 16:09:38.466: W/System.err(26546): at android.app.Instrumentation.callActivityOnStart(Instrumentation.java:1201) 01-11 16:09:38.466: W/System.err(26546): at android.app.Activity.performStart(Activity.java:3955) 01-11 16:09:38.466: W/System.err(26546): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1845) 01-11 16:09:38.466: W/System.err(26546): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1893) 01-11 16:09:38.466: W/System.err(26546): at android.app.ActivityThread.
Tags (comma-separated)
Save Edits
Cancel