Added in [API level 23](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels) Summary: [Ctors](https://developer.android.com/reference/android/hardware/camera2/CameraManager.TorchCallback#pubctors) \| [Methods](https://developer.android.com/reference/android/hardware/camera2/CameraManager.TorchCallback#pubmethods) \| [Inherited Methods](https://developer.android.com/reference/android/hardware/camera2/CameraManager.TorchCallback#inhmethods)

# CameraManager.TorchCallback

*** ** * ** ***

` public static abstract class CameraManager.TorchCallback `   
` extends https://developer.android.com/reference/java/lang/Object ` ` `

|---|---|
| [java.lang.Object](https://developer.android.com/reference/java/lang/Object) ||
| ↳ | android.hardware.camera2.CameraManager.TorchCallback |

<br />

*** ** * ** ***

A callback for camera flash torch modes becoming unavailable, disabled, or enabled.

The torch mode becomes unavailable when the camera device it belongs to becomes unavailable or other camera resources it needs become busy due to other higher priority camera activities. The torch mode becomes disabled when it was turned off or when the camera device it belongs to is no longer in use and other camera resources it needs are no longer busy. A camera's torch mode is turned off when an application calls `https://developer.android.com/reference/android/hardware/camera2/CameraManager#setTorchMode(java.lang.String,%20boolean)` to turn off the camera's torch mode, or when an application turns on another camera's torch mode if keeping multiple torch modes on simultaneously is not supported. The torch mode becomes enabled when it is turned on via `https://developer.android.com/reference/android/hardware/camera2/CameraManager#setTorchMode(java.lang.String,%20boolean)`.

The torch mode is available to set via `https://developer.android.com/reference/android/hardware/camera2/CameraManager#setTorchMode(java.lang.String,%20boolean)` only when it's in a disabled or enabled state.

Extend this callback and pass an instance of the subclass to `https://developer.android.com/reference/android/hardware/camera2/CameraManager#registerTorchCallback(android.hardware.camera2.CameraManager.TorchCallback,%20android.os.Handler)` to be notified of such status changes.

<br />

**See also:**

- `https://developer.android.com/reference/android/hardware/camera2/CameraManager#registerTorchCallback(android.hardware.camera2.CameraManager.TorchCallback,%20android.os.Handler)`

## Summary

| ### Public constructors ||
|---|---|
| ` https://developer.android.com/reference/android/hardware/camera2/CameraManager.TorchCallback#TorchCallback()() ` |

| ### Public methods ||
|---|---|
| ` void` | ` https://developer.android.com/reference/android/hardware/camera2/CameraManager.TorchCallback#onTorchModeChanged(java.lang.String,%20boolean)(https://developer.android.com/reference/java/lang/String cameraId, boolean enabled) ` A camera's torch mode has become enabled or disabled and can be changed via `https://developer.android.com/reference/android/hardware/camera2/CameraManager#setTorchMode(java.lang.String,%20boolean)`. |
| ` void` | ` https://developer.android.com/reference/android/hardware/camera2/CameraManager.TorchCallback#onTorchModeUnavailable(java.lang.String)(https://developer.android.com/reference/java/lang/String cameraId) ` A camera's torch mode has become unavailable to set via `https://developer.android.com/reference/android/hardware/camera2/CameraManager#setTorchMode(java.lang.String,%20boolean)`. |
| ` void` | ` https://developer.android.com/reference/android/hardware/camera2/CameraManager.TorchCallback#onTorchStrengthLevelChanged(java.lang.String,%20int)(https://developer.android.com/reference/java/lang/String cameraId, int newStrengthLevel) ` A camera's flash unit brightness level has been changed in torch mode via `https://developer.android.com/reference/android/hardware/camera2/CameraManager#turnOnTorchWithStrengthLevel(java.lang.String,%20int)`. |

### Inherited methods

From class ` https://developer.android.com/reference/java/lang/Object ` ` https://developer.android.com/reference/java/lang/Object` ` https://developer.android.com/reference/java/lang/Object#clone()() `

Creates and returns a copy of this object.
` boolean` ` https://developer.android.com/reference/java/lang/Object#equals(java.lang.Object)(https://developer.android.com/reference/java/lang/Object obj) `

Indicates whether some other object is "equal to" this one.
` void` ` https://developer.android.com/reference/java/lang/Object#finalize()() `

Called by the garbage collector on an object when garbage collection determines that there are no more references to the object.
` final https://developer.android.com/reference/java/lang/Class<?>` ` https://developer.android.com/reference/java/lang/Object#getClass()() `

Returns the runtime class of this `Object`.
` int` ` https://developer.android.com/reference/java/lang/Object#hashCode()() `

Returns a hash code value for the object.
` final void` ` https://developer.android.com/reference/java/lang/Object#notify()() `

Wakes up a single thread that is waiting on this object's monitor.
` final void` ` https://developer.android.com/reference/java/lang/Object#notifyAll()() `

Wakes up all threads that are waiting on this object's monitor.
` https://developer.android.com/reference/java/lang/String` ` https://developer.android.com/reference/java/lang/Object#toString()() `

Returns a string representation of the object.
` final void` ` https://developer.android.com/reference/java/lang/Object#wait(long,%20int)(long timeoutMillis, int nanos) `

Causes the current thread to wait until it is awakened, typically by being *notified* or *interrupted*, or until a certain amount of real time has elapsed.
` final void` ` https://developer.android.com/reference/java/lang/Object#wait(long)(long timeoutMillis) `

Causes the current thread to wait until it is awakened, typically by being *notified* or *interrupted*, or until a certain amount of real time has elapsed.
` final void` ` https://developer.android.com/reference/java/lang/Object#wait()() `

Causes the current thread to wait until it is awakened, typically by being *notified* or *interrupted*.

## Public constructors

### TorchCallback

```
public TorchCallback ()
```

<br />

<br />

## Public methods

### onTorchModeChanged

Added in [API level 23](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public void onTorchModeChanged (String cameraId, 
                boolean enabled)
```

A camera's torch mode has become enabled or disabled and can be changed via `https://developer.android.com/reference/android/hardware/camera2/CameraManager#setTorchMode(java.lang.String,%20boolean)`.

The default implementation of this method does nothing.

<br />

<br />

| Parameters ||
|---|---|
| `cameraId` | `String`: The unique identifier of the camera whose torch mode has been changed. This value cannot be `null`. <br /> |
| `enabled` | `boolean`: The state that the torch mode of the camera has been changed to. `true` when the torch mode has become on and available to be turned off. `false` when the torch mode has becomes off and available to be turned on. <br /> |

### onTorchModeUnavailable

Added in [API level 23](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public void onTorchModeUnavailable (String cameraId)
```

A camera's torch mode has become unavailable to set via `https://developer.android.com/reference/android/hardware/camera2/CameraManager#setTorchMode(java.lang.String,%20boolean)`.

If torch mode was previously turned on by calling `https://developer.android.com/reference/android/hardware/camera2/CameraManager#setTorchMode(java.lang.String,%20boolean)`, it will be turned off before `https://developer.android.com/reference/android/hardware/camera2/CameraManager.TorchCallback#onTorchModeUnavailable(java.lang.String)` is invoked. `https://developer.android.com/reference/android/hardware/camera2/CameraManager#setTorchMode(java.lang.String,%20boolean)` will fail until the torch mode has entered a disabled or enabled state again.

The default implementation of this method does nothing.

<br />

<br />

| Parameters ||
|---|---|
| `cameraId` | `String`: The unique identifier of the camera whose torch mode has become unavailable. This value cannot be `null`. <br /> |

### onTorchStrengthLevelChanged

Added in [API level 33](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public void onTorchStrengthLevelChanged (String cameraId, 
                int newStrengthLevel)
```

A camera's flash unit brightness level has been changed in torch mode via `https://developer.android.com/reference/android/hardware/camera2/CameraManager#turnOnTorchWithStrengthLevel(java.lang.String,%20int)`. When the torch is turned OFF, this callback will not be triggered even though the torch strength level resets to default value `https://developer.android.com/reference/android/hardware/camera2/CameraCharacteristics#FLASH_INFO_STRENGTH_DEFAULT_LEVEL`

The default implementation of this method does nothing.

<br />

<br />

| Parameters ||
|---|---|
| `cameraId` | `String`: The unique identifier of the camera whose flash unit brightness level has been changed. This value cannot be `null`. <br /> |
| `newStrengthLevel` | `int`: The brightness level of the flash unit that has been changed to. <br /> |