Capture Reference

Everything you need to customize your Lens camera on Android

Below is a reference to customize your camera beyond basic integration. The camera itself has no user interface elements, allowing you to customize the look and feel to match your app's existing style. The SDK provides additional API for interacting with the camera's controls, initiating capture, turning flash on and off, etc.

Camera Methods

Set zoom ratio

void setZoomRatio(float zoomRatio)

Tell the camera how much to zoom.


Adjust metering mode

void focusMeteringOnTap(MotionEvent motionEvent, int meteringMode, @Nullable Runnable focusMeteringOnTapCallBack)

Tell the camera which metering mode to use.


Set front facing preview mirroring

void setIsFrontFacingPreviewMirrored(boolean mirrored)

Set front facing preview mirroring (this does not impact the captured image, or rear facing camera).


Get front facing preview mirroring

boolean getIsFrontFacingPreviewMirrored()

Gets the current mirroring status for the front facing camera.


Set flash mode

void setFlashMode(LensFlashMode lensFlashMode)

Sets the flash mode Off, Auto, and On. See flash enum.


Set camera direction

void setLensFacing(LensCameraFacing lensCameraFacing)

Sets whether the camera is set to front (AKA selfie) or back.


Set preview scaling

void setPreviewScale(LensPreviewScale LensPreviewScale)

Sets preview scaling to fit or fill. See preview scale enum.


Get preview aspect ratio

LensPreviewAspectRatio getPreviewAspectRatio()

Gets current aspect ratio of a preview. Response might differ based on the capture mode. See preview aspect ratio enum.


Get preview bitmap

bitmap getPreviewBitmap()

Extracts bitmap from preview.


Get location accuracy threshold

float getLocationAccuracyThreshold()

Gets the location accuracy threshold, in meters. The default value is 1500, or 2500, if precise location is not required.


Set location accuracy threshold

void setLocationAccuracyThreshold(float)

Sets the location accuracy threshold, in meters. Use caution when setting this value, as this radius determines when the camera is enabled. The default value is 1500, or 2500, if precise location is not required.


Set location requirements

void setLocationRequirement(LensLocationMode lensLocationMode, boolean preciseLocationRequired)

Sets the location requirements for the capture. Three options are available: required, optional and never (see location requirements enum).


Audio Methods

Start recording audio

void startRecordingAudio(LensAudioCaptureHandler lensAudioCaptureHandler)

Tell the SDK to start record audio.

Stop recording audio

void stopRecordingAudio(LensAudioCaptureHandler lensAudioCaptureHandler)

Tell the SDK to stop record audio.

Set audio directory

void setAudioDirectory(String audioDirectory)

Set a directory for the audio file.

Get audio amplitude

int getMaxAmplitude()

Gets the audio recording amplitude.


Enums

Flash

public enum LensFlashMode {
    Off,
    Auto,
    On
}

Camera facing

public enum LensCameraFacing {
    Rear,
    Front
}

Preview scale

Choosing LensPreviewScale.FIT will show everything in the preview, but letterboxing is introduced in case viewport doesn't match preview aspect ratio. LensPreviewScale.FILL will make preview fill entire view port. If preview aspect ratio is different than viewport aspect ratio, then cropping is introduced.

public enum LensPreviewScale {
    FIT,
    FILL
}

Preview aspect ratio

public enum LensPreviewAspectRatio {
    RATIO_16_9,
    RATIO_4_3
}

Location requirements

Lens SDK will automatically include location in the captures, but this behavior could be modified by calling setLocationRequirement method. It is also possible to only require coarse location, if fine location accuracy is not needed, but keep in mind that setLocationAccuracyThreshold must be large enough for such cases. If LensLocationMode.Optional is selected, SDK will determine the location requirements based on the available permissions. Lastly, setLocationRequirement should be called before setApiKey.

public enum LensLocationMode {
    Required,
    Optional,
    Never
}

Events

Handling the standard Android motion events is left for the implementor to determine. We provide an example implementation in the Sample Code section.


Offline Capture

Lens offers out of the box support for capturing and signing photos and videos offline, which can be uploaded to your server or directly to the Lens API when the device regains connectivity. See the dedicated section about offline capture to learn more.