CameraManager.SetTorchMode(String, Boolean) Method
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Set the flash unit's torch mode of the camera of the given ID without opening the camera device.
[Android.Runtime.Register("setTorchMode", "(Ljava/lang/String;Z)V", "", ApiSince=23)]
public void SetTorchMode (string cameraId, bool enabled);
[<Android.Runtime.Register("setTorchMode", "(Ljava/lang/String;Z)V", "", ApiSince=23)>]
member this.SetTorchMode : string * bool -> unit
Parameters
- cameraId
- String
The unique identifier of the camera device that the flash unit belongs to.
- enabled
- Boolean
The desired state of the torch mode for the target camera device. Set to
true
to turn on the torch mode. Set to false
to turn off the
torch mode.
- Attributes
Remarks
Set the flash unit's torch mode of the camera of the given ID without opening the camera device.
Use #getCameraIdList
to get the list of available camera devices and use #getCameraCharacteristics
to check whether the camera device has a flash unit. Note that even if a camera device has a flash unit, turning on the torch mode may fail if the camera device or other camera resources needed to turn on the torch mode are in use.
If #setTorchMode
is called to turn on or off the torch mode successfully, CameraManager.TorchCallback#onTorchModeChanged
will be invoked. However, even if turning on the torch mode is successful, the application does not have the exclusive ownership of the flash unit or the camera device. The torch mode will be turned off and becomes unavailable when the camera device that the flash unit belongs to becomes unavailable or when other camera resources to keep the torch on become unavailable ( CameraManager.TorchCallback#onTorchModeUnavailable
will be invoked). Also, other applications are free to call #setTorchMode
to turn off the torch mode ( CameraManager.TorchCallback#onTorchModeChanged
will be invoked). If the latest application that turned on the torch mode exits, the torch mode will be turned off.
Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.