Turn off Flashlight on Android Lollipop version -


kcamera = camera.open(); kcamera.parameters cam1= k.camera.getparameters(); cam1.setflashmode(parameters.flash_mode_torch); kcamera.setparameters(cam1); surfacetexture mpreviewtexture = new surfacetexture(0); try {      kcamera.setpreviewtexture(mpreviewtexture); } catch { } mcam.startpreview(); 

this works fine, opens flashlight.

but how can turn off ?

from documentation:

public static final string flash_mode_off

added in api level 5 flash not fired.

constant value: "off"

so, can define function this:

public void turnoffflashlight(camera camera){         camera.parameters cam1 = camera.getparameters();         cam1.setflashmode(camera.parameters.flash_mode_off);         kcamera.setparameters(cam1);     } 

and then, use when need:

turnoffflashlight(kcamera); 

Comments

Popular posts from this blog

toolbar - How to add link to user registration inside toobar in admin joomla 3 custom component -

linux - disk space limitation when creating war file -