Camera.Parameters.FLASH_MODE_TORCH replacement for Android 2.1 -


i trying write app requires led flash go torch mode. problem is, android 2.1 not support mode , therefore cannot support platform yet. wouldn't issue, writing fiance , epic 4g has 2.1 right now. found code samples use undocumented api calls , therefore work on motorola droid , such, not work on epic. have suggestions on find code should me working?

i'm finding torch mode working fine on 2.1 had same problem samsung epic , found hack around it.

looking @ params returned camera.getparameters() when run on samsung epic, noticed flash-modes claims support are: flash-mode-values=off,on,auto;

torch-mode not listed, implying it's not supported.

however, found model still accept mode , turn led on! bad news when later setting flash-mode auto or off left led still lit! not turn off until call camera.release().

i guess that's why samsung dont include in list of supported!?!

so...the method use toggle torch in camerahelper class is...

/***  * attempts set camera flash torch/flashlight mode on/off  * @param ison true = on, false = off  * @return boolean whether or not able set  */ public boolean setflashlight(boolean ison) {     if (mcamera == null)     {         return false;     }     camera.parameters params = mcamera.getparameters();     string value;     if (ison) // being ask turn on     {         value = camera.parameters.flash_mode_torch;     }     else  // being asked turn off     {         value =  camera.parameters.flash_mode_auto;     }      try{             params.setflashmode(value);         mcamera.setparameters(params);          string nowmode = mcamera.getparameters().getflashmode();          if (ison && nowmode.equals(camera.parameters.flash_mode_torch))         {             return true;         }         if (! ison && nowmode.equals(camera.parameters.flash_mode_auto))         {             return true;         }         return false;     }     catch (exception ex)     {         mylog.e(mlog_tag, this.getclass().getsimplename() +  " error setting flash mode to: "+ value + " " + ex.tostring());     } } 

the activities use call follows...

private void toggleflashlight() {     misflashlighton = ! misflashlighton;      /**      * hack fix issue samsung galaxy turn torch on,      * though says doesnt support torch mode,      * not turn off via param.      */     if (! misflashlighton && build.manufacturer.equalsignorecase("samsung"))     {         this.releasecameraresources();         this.initcamera();     }     else     {         boolean result = mcamhelper.setflashlight(misflashlighton);         if (! result)         {             alertflashlightnotsupported();         }     } } 

the magic makes work in releasecameraresources() calls camera.release()....and have reinitialize camera stuff samsung devices.

not pretty seems working plenty of users.

note have report of torch mode not working @ code on nexus 1 have been able dig it. works on htc evo , samsung epic.

hope helps.


Comments

Popular posts from this blog

ASP.NET/SQL find the element ID and update database -

jquery - appear modal windows bottom -

c++ - Compiling static TagLib 1.6.3 libraries for Windows -