How to control camera flash light with camera2 API -


i want control flash light of smartphone (galaxy s6) using camera2 api.

i checked available codes this,

try {     cameramanager mmanager = (cameramanager) getsystemservice(context.camera_service);     string [] cameraid = mmanager.getcameraidlist();     cameracharacteristics cameracharacteristics = mmanager.getcameracharacteristics(cameraid[1]);     toast.maketext(getapplicationcontext(),cameraid[0]+cameraid[1],toast.length_long).show();     boolean flashavailable = cameracharacteristics.get(cameracharacteristics.flash_info_available);     if (flashavailable) {         mmanager.opencamera(cameraid[0], new mystatecallback(), null);         toast.maketext(getapplicationcontext(),"flash available",toast.length_long).show();     } else {         //todo: throw exception         toast.maketext(getapplicationcontext(),"flash not available",toast.length_long).show();     } } catch (exception e) {     e.printstacktrace(); } 

but, toast message : flash not available.

of course, declared permission , hardware features in manifest.

is impossible control flash light device or camera2 api?

you're checking whether second camera (probably front-facing one) has flash, because you're getting camera characteristics cameraid[1] instead of cameraid[0] on 4th line.

typically, back-facing camera first, , 1 flash. robust, iterate on camera ids , check if of them has flash.


Comments

Popular posts from this blog

c# - Better 64-bit byte array hash -

webrtc - Which ICE candidate am I using and why? -

php - Zend Framework / Skeleton-Application / Composer install issue -