Start a new topic

Android Camera FlashLight

Android Camera FlashLight


Hello everybody.

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?

 

 

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.


Default: false



hardware.flashlightAvailable
 Boolean


 



true if the device has a flashlight, false otherwise. 
 

Note that the following permissions are required on Android: 

<uses-permission android:name="android.permission.FLASHLIGHT"/> 
<uses-feature android:name="android.hardware.camera.flash" />


Default: false

 

Best regards

Andreas

Thanks again Andreas, really I didn't know for use the flashlight with JS.

But in documentation I don't find the example o the instructions for do that.

Can you help me please?

Thanks.
Login or Signup to post a comment