CameraInfo

interface CameraInfo
androidx.camera.core.CameraInfo

An interface for retrieving camera information.

Applications can retrieve an instance via Camera#getCameraInfo().

Summary

Public methods

abstract LiveData<Float!>

Returns a LiveData of current linearZoom which is in range [0.

abstract LiveData<Float!>

Returns a LiveData of the maximum zoom ratio.

abstract LiveData<Float!>

Returns a LiveData of the minimum zoom ratio.

abstract Int

Returns the sensor rotation in degrees, relative to the device's "natural" (default) orientation.

abstract Int
getSensorRotationDegrees(relativeRotation: Int)

Returns the sensor rotation, in degrees, relative to the given rotation value.

abstract LiveData<Int!>

Returns a LiveData of current TorchState.

abstract LiveData<Float!>

Returns a LiveData of current zoom ratio.

abstract Boolean

Returns if flash unit is available or not.

Public methods

getLinearZoom

@NonNull abstract fun getLinearZoom(): LiveData<Float!>

Returns a LiveData of current linearZoom which is in range [0..1]. LinearZoom 0 represents the minimum zoom while linearZoom 1.0 represents the maximum zoom.

Apps can either get immediate value via LiveData#getValue() (The value is never null, it has default value in the beginning) or they can observe it via LiveData#observe(LifecycleOwner, Observer) to update zoom UI accordingly.

Setting zoomRatio or linearZoom will both trigger the change event.

Return
LiveData<Float!>: a LiveData containing current linearZoom.

getMaxZoomRatio

@NonNull abstract fun getMaxZoomRatio(): LiveData<Float!>

Returns a LiveData of the maximum zoom ratio.

Apps can either get immediate value via LiveData#getValue() (The value is never null, it has default value in the beginning) or they can observe it via LiveData#observe(LifecycleOwner, Observer) to update zoom UI accordingly.

While the value is fixed most of the time, enabling extension could change the maximum zoom ratio.

Return
LiveData<Float!>: a LiveData containing the maximum zoom ratio value.

getMinZoomRatio

@NonNull abstract fun getMinZoomRatio(): LiveData<Float!>

Returns a LiveData of the minimum zoom ratio.

Apps can either get immediate value via LiveData#getValue() (The value is never null, it has default value in the beginning) or they can observe it via LiveData#observe(LifecycleOwner, Observer) to update zoom UI accordingly.

While the value is fixed most of the time, enabling extension could change the minimum zoom ratio value.

Return
LiveData<Float!>: a LiveData containing the minimum zoom ratio value.

getSensorRotationDegrees

abstract fun getSensorRotationDegrees(): Int

Returns the sensor rotation in degrees, relative to the device's "natural" (default) orientation.

Return
Int: The sensor rotation in degrees, relative to device's "natural" (default) orientation.

See Also

  • <a href="https://developer.android.com/guide/topics/sensors/sensors_overview#sensors-coords">

getSensorRotationDegrees

abstract fun getSensorRotationDegrees(relativeRotation: Int): Int

Returns the sensor rotation, in degrees, relative to the given rotation value.

Valid values for the relative rotation are Surface#ROTATION_0 (natural), , Surface#ROTATION_180, Surface#ROTATION_270.

Parameters
relativeRotation Int: The rotation relative to which the output will be calculated.
Return
Int: The sensor rotation in degrees.

getTorchState

@NonNull abstract fun getTorchState(): LiveData<Int!>

Returns a LiveData of current TorchState.

The torch can be turned on and off via CameraControl#enableTorch(boolean) which will trigger the change event to the returned LiveData. Apps can either get immediate value via LiveData#getValue() or observe it via LiveData#observe(LifecycleOwner, Observer) to update torch UI accordingly.

If the camera doesn't have a flash unit (see hasFlashUnit()), then the torch state will be TorchState#OFF.

Return
LiveData<Int!>: a LiveData containing current torch state.

getZoomRatio

@NonNull abstract fun getZoomRatio(): LiveData<Float!>

Returns a LiveData of current zoom ratio.

Apps can either get immediate value via LiveData#getValue() (The value is never null, it has default value in the beginning) or they can observe it via LiveData#observe(LifecycleOwner, Observer) to update zoom UI accordingly.

Setting zoomRatio or linearZoom will both trigger the change event.

Return
LiveData<Float!>: a LiveData containing current zoom ratio.

hasFlashUnit

abstract fun hasFlashUnit(): Boolean

Returns if flash unit is available or not.