Android Camera FlashLight

Bodoquezorrilla

Bodoquezorrilla

I want to know how can I turn on/off the flashlight from the device camera, using a button.

I use this code, but it isn't work:

camera = Camera.open();

Parameters p = camera.getParameters();

p.setFlashMode(Parameters.FLASH_MODE_TORCH);

camera.setParameters(p);

camera.startPreview();

PD: Extra question, Why when I have my wikitude app in background, I can't open the Native Camera app?

A

Andreas Schacherbauer

said
about 4 years ago

Hi Sergio, Do you know that you can activate the flashlight with a JS API that we have introduced with the SDK 4.0?

I talked with our Android developer and he told me that you need to call the activity life cycle methods like onCreate, onPostCreate, ... on your ArchiteView object. You can find a example on what you need to do exactly in the AbstractArchitectCamActivity.java.

hardware.flashlight Boolean

Turns the device flashlight on or off. Use the isFlashlightAvailable property to check if the device has a flashlight or not. If the device has no flashlight and the property is set to true, this will have no effect.