Camera cameraObj = Camera.open(); Parameters params = cameraObj.getParameters(); params.setFocusMode(Parameters.FOCUS_MODE_AUTO); cameraObj.setParameters(params); cameraObj.autoFocus(new Camera.AutoFocusCallback(){ @Override public void onAutoFocus(boolean success, Camera camera){ if(success){ //take picture or start video recording camera.takePicture(null, null, mPictureCallback); } else { //handle focus error } } });In this example, we first open the camera and get its parameters. Then, we set the focus mode to auto, and set the camera parameters. We then call the autoFocus method on the camera object, passing in an auto-focus callback function. If the auto-focus succeeds, we can take a picture or start recording a video. Otherwise, we can handle the error. The package library for this method is: android.hardware.