public interface

ImageCapture.ScreenFlash

 androidx.camera.core.ImageCapture.ScreenFlash

Overview

Interface to do the application changes required for screen flash operations.

Each ImageCapture.ScreenFlash.apply(long, ImageCapture.ScreenFlashListener) invocation will be followed up with a corresponding ImageCapture.ScreenFlash.clear() invocation. For each image capture, #apply and #clear will be invoked only once.

Summary

Methods
public voidapply(long expirationTimeMillis, ImageCapture.ScreenFlashListener screenFlashListener)

Applies the necessary application changes for a screen flash photo capture.

public voidclear()

Clears any application change done for screen flash operation, if required.

Methods

public void apply(long expirationTimeMillis, ImageCapture.ScreenFlashListener screenFlashListener)

Applies the necessary application changes for a screen flash photo capture.

When the application UI needs to be changed for a successful photo capture with screen flash feature, CameraX will invoke this method and wait for the application to complete its changes. When this API is invoked, the application UI should utilize the screen to provide extra light as an alternative to physical flash. For example, the screen brightness can be maximized and screen color can be covered with some bright color like white.

The parameter expirationTimeMillis is based on currentTimeMillis. It is at least 3 seconds later from the start of a screen flash image capture operation. Until the timestamp of expirationTimeMillis parameter, CameraX will wait for the application to notify the completion of the application-side changes using the ImageCapture.ScreenFlashListener parameter of this method. Applications must call ImageCapture.ScreenFlashListener.onCompleted() after their UI changes are done so that CameraX is not unnecessarily waiting. If the application does not call ScreenFlashListener#onCompleted before expirationTimeMillis, CameraX will stop waiting and move forward with the subsequent operations regardless. In such case, the application no longer needs to call ScreenFlashListener#onCompleted(). If ImageCapture.ScreenFlash.clear() has also been invoked while the application is still doing the changes, it is the application's responsibility to clear any UI change done after ImageCapture.ScreenFlash.clear() has been invoked.

The following code snippet shows an example implementation of this API.

{@code

Parameters:

expirationTimeMillis: The timestamp after which CameraX will no longer listen to screenFlashListener.
screenFlashListener: Used to notify when UI changes have been applied.

public void clear()

Clears any application change done for screen flash operation, if required.

CameraX will invoke this method when a screen flash photo capture has been completed and the application screen can be safely changed to a state not conforming to screen flash photo capture.