# Enabling/disabling torch while in session

**URL:** <https://devforum.zoom.us/t/enabling-disabling-torch-while-in-session/56795>\
**Category:** Android\
**Created:** [September 1, 2021, 3:14pm UTC](https://devforum.zoom.us/t/enabling-disabling-torch-while-in-session/56795 "2021-09-01T15:14:49Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![wbaroudi](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/wbaroudi/32/30319_2.png) [@wbaroudi](https://devforum.zoom.us/u/wbaroudi)\
**Post date:** [September 1, 2021, 3:14pm UTC](https://devforum.zoom.us/t/enabling-disabling-torch-while-in-session/56795/1 "2021-09-01T15:14:49Z")

</div>

**Description**  
Hi,  
I have been trying to figure out a way to turn on the torch for the rear camera while in a session.  
I failed to find a way specific to the SDK, so I used the usual method via the CameraManager as follows:

```auto
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
            val manager = requireContext().getSystemService(Context.CAMERA_SERVICE) as CameraManager
            manager.setTorchMode(camID, enable)
        } else {
            // todo: Handle for lower API levels
        }

```

however, expectedly, this results in an error with the following message:

> Torch for camera “0” is not available due to an existing camera user

is there a safe way to turn on the torch while in session?

Thanks!  
**Which Android Video SDK version?**  
v1.1.1 (8665.0812)

---

<div class="post-metadata">

**Author:** ![jon.zoom](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/jon.zoom/32/13495_2.png) [@jon.zoom](https://devforum.zoom.us/u/jon.zoom)\
**Post date:** [September 8, 2021, 4:57pm UTC](https://devforum.zoom.us/t/enabling-disabling-torch-while-in-session/56795/2 "2021-09-08T16:57:51Z")

</div>

Hi @wbaroudi, thanks for the post.

The SDK should not be doing anything that would prevent you from programmatically turning on the torch. I have tested this and can properly turn it on 100% of the time. Are you certain that you are using the correct ID of the camera? Is this issue specific to any device makes/models?

Thanks!

---

<div class="post-metadata">

**Author:** ![wbaroudi](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/wbaroudi/32/30319_2.png) [@wbaroudi](https://devforum.zoom.us/u/wbaroudi)\
**Post date:** [September 9, 2021, 6:10pm UTC](https://devforum.zoom.us/t/enabling-disabling-torch-while-in-session/56795/3 "2021-09-09T18:10:59Z")

</div>

Hi Jon,  
Are you using the same native way I mentioned in the post?  
I’m pretty sure this doesn’t work when you use the same device for preview, which will always be the case for phones with a single back camera.  
My phone has multiple back cameras, I looped over them and turned the flash on for all of them, this worked. it turned the torch on for the camera with ID 2, while the camera the Zoom SDK is using has ID 0. this is alright as long as the phone has multiple back cameras.  
Also, getting the camera device list from the VideoHelper in the SDK only gives 2 devices with IDs 0 and 1. However, getting it from the CameraManager gives more devices, which I assume are the separate back cameras. So, technically the zoom SDK does not recognize the other back camera devices, which means that, by design, it should not allow enabling torch using the native method, or am I wrong?

Thank you!

---

<div class="post-metadata">

**Author:** ![Michael\_Condon](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/michael_condon/32/13543_2.png) [@Michael\_Condon](https://devforum.zoom.us/u/Michael_Condon)\
**Post date:** [September 13, 2021, 9:55pm UTC](https://devforum.zoom.us/t/enabling-disabling-torch-while-in-session/56795/4 "2021-09-13T21:55:39Z")

</div>

Hey @wbaroudi,

@jon.zoom is currently out, but will be back this week to follow up with you 🙂

Thanks!  
Michael

---

<div class="post-metadata">

**Author:** ![jon.zoom](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/jon.zoom/32/13495_2.png) [@jon.zoom](https://devforum.zoom.us/u/jon.zoom)\
**Post date:** [September 14, 2021, 9:39pm UTC](https://devforum.zoom.us/t/enabling-disabling-torch-while-in-session/56795/5 "2021-09-14T21:39:51Z")

</div>

Hi @wbaroudi,

After doing some more investigation on this, it does appear that camera access is restricted only when attempting to use the same camera that the SDK is currently using. Since the SDK only swaps between front and back instead of individual cameras, the only workaround available at this time would be to temporarily switch cameras whenever you need to change the torch mode.

We’ll investigate adding better support for this in the future and keep you updated.

Thanks!

---

<div class="post-metadata">

**Author:** ![wbaroudi](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/wbaroudi/32/30319_2.png) [@wbaroudi](https://devforum.zoom.us/u/wbaroudi)\
**Post date:** [September 14, 2021, 11:07pm UTC](https://devforum.zoom.us/t/enabling-disabling-torch-while-in-session/56795/6 "2021-09-14T23:07:17Z")

</div>

Hi @jon.zoom, welcome back 😃  
Yup, that’s what I was trying to point out.  
Great, I’ll be looking forward to hearing back from you.

Thanks!

---

<div class="post-metadata">

**Author:** ![jon.zoom](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/jon.zoom/32/13495_2.png) [@jon.zoom](https://devforum.zoom.us/u/jon.zoom)\
**Post date:** [September 16, 2021, 1:00am UTC](https://devforum.zoom.us/t/enabling-disabling-torch-while-in-session/56795/7 "2021-09-16T01:00:24Z")

</div>

Hi @wbaroudi,

I just wanted to let you know that we have added this feature to our long term backlog. We don’t have an exact idea of when this will be included, but it should be added at some point in the future.

If you aren’t already aware, the best place to keep track of new releases is our [release notes page](https://marketplace.zoom.us/docs/changelog). 🙂

Thanks!

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex016/uploads/zoomdeveloper/original/3X/6/1/614bdd549b610bbaa46ff934617683a02bdaa03c.png) [@system](https://devforum.zoom.us/u/system)\
**Post date:** [October 16, 2021, 11:01am UTC](https://devforum.zoom.us/t/enabling-disabling-torch-while-in-session/56795/8 "2021-10-16T11:01:01Z")

</div>

Closed on October 16, 2021, 11:01am UTC

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.
