Android.Hardware.Camera.AutoFocus Method
Starts camera auto-focus and registers a callback function to run when the camera is focused.

Syntax

[Android.Runtime.Register("autoFocus", "(Landroid/hardware/Camera$AutoFocusCallback;)V", "")]
public void AutoFocus (Camera.IAutoFocusCallback cb)

See Also

Camera.CancelAutoFocus
Android.Media.MediaActionSound

Parameters

cb
the callback to run

Remarks

Starts camera auto-focus and registers a callback function to run when the camera is focused. This method is only valid when preview is active (between Camera.StartPreview and before Camera.StopPreview).

Callers should check NoType:android/hardware/Camera$Parameters;Href=../../../reference/android/hardware/Camera.Parameters.html#getFocusMode() to determine if this method should be called. If the camera does not support auto-focus, it is a no-op and NoType:android/hardware/Camera$AutoFocusCallback;Href=../../../reference/android/hardware/Camera.AutoFocusCallback.html#onAutoFocus(boolean, android.hardware.Camera) callback will be called immediately.

If your application should not be installed on devices without auto-focus, you must declare that your application uses auto-focus with the <uses-feature> manifest element.

If the current flash mode is not NoType:android/hardware/Camera$Parameters;Href=../../../reference/android/hardware/Camera.Parameters.html#FLASH_MODE_OFF, flash may be fired during auto-focus, depending on the driver and camera hardware.

Auto-exposure lock NoType:android/hardware/Camera$Parameters;Href=../../../reference/android/hardware/Camera.Parameters.html#getAutoExposureLock() and auto-white balance locks NoType:android/hardware/Camera$Parameters;Href=../../../reference/android/hardware/Camera.Parameters.html#getAutoWhiteBalanceLock() do not change during and after autofocus. But auto-focus routine may stop auto-exposure and auto-white balance transiently during focusing.

Stopping preview with Camera.StopPreview, or triggering still image capture with Camera.TakePicture(.IShutterCallback, .IPictureCallback, .IPictureCallback), will not change the the focus position. Applications must call cancelAutoFocus to reset the focus.

If autofocus is successful, consider using Android.Media.MediaActionSound to properly play back an autofocus success sound to the user.

[Android Documentation]

Requirements

Namespace: Android.Hardware
Assembly: Mono.Android (in Mono.Android.dll)
Assembly Versions: 0.0.0.0
Since: Added in API level 1