Skip to content

Using commands#

This topic applies to LUNA ID for Android only.

LUNA ID for Android provides controls to manage a camera:

StartBestShotSearchCommand#

You can use the StartBestShotSearchCommand command to start a best shot search at any specified moment, that is after some event or a fixed delay.

If specified in Commands, a call to LunaID.showCamera does not automatically start the best shot search. To start the best shot search, you need to send the command with LunaID.sendCommand(StartBestShotSearchCommand).

CloseCameraCommand#

You can use the CloseCameraCommand command you to specify when to close a camera after the best shot was found.

If specified in Commands, the camera will not be closed automatically when the best shot search finishes. Currently, this is the default behavior. You will still receive the LunaID.FinishResult finish event. You need to close the camera by calling LunaID.sendCommand(CloseCameraCommand).

Usage#

To use the commands, you need to do the following:

1․ Create the Commands instance with commands that you want to use:

Commands.Builder().apply {
            override(StartBestShotSearchCommand)
            override(CloseCameraCommand)
        }.build()

All the commands override the default behavior when specified. Only the specified commands will be accepted. If you try to send unspecified commands, an exception will be thrown.

2․ Call the LunaID.showCamera() method with the Commands instance.

If you do not specify commands, you can expect the default behavior. Nothing will change for you compared to the previous LUNA ID versions.

        LunaID.showCamera(
            ...
            commands = ...,
        )

3․ Send any command with LunaID.sendCommand().

Example#

You can find a detailed example of how to use the StartBestShotSearchCommand and CloseCameraCommand commands in CameraExample.