java - Implementing strobe (Flash Light Blinking) effect on android which blinks with the same frequency -


I am implementing strobe functionality that works fine (LED camera flash light ON / OFF) I am turning on / off with different frequency in different devices. Its blinking in HTC SensationXE is fast and its blinking in the Nexus does not know at the moment that what the problem is, anybody can help please: this code :

  / * * This method LED camera flash light * / Public Zero Flash LightOn () {Log D. ("Time", "on"); If (! IsFlashOn) {if (cam! = Null || params! = Null) {params.setFlashMode (Parameters.FLASH_MODE_TORCH); Cam.setParameters (parameter); Cam.startPreview (); IsFlashOn = True; } Else {cam = Camera.open (); Params = cam.getParameters (); Params.setFlashMode (Parameters.FLASH_MODE_TORCH); Cam.setParameters (parameter); Cam.startPreview (); IsFlashOn = True; }} And {return; }} / * * This method has LED camera flash light * / Public Wide Flash Lightoff () {Log D. ("Time", "off"); If (isFlashOn) {if (cam! = Null || params! = Null) {//params.setFlashMode(Parameters.FLASH_MODE_OFF); //cam.setParameters(params); Cam.stopPreview (); IsFlashOn = false; } And {// params = cam.getParameters (); //params.setFlashMode(Parameters.FLASH_MODE_OFF); //cam.setParameters(params); Cam.stopPreview (); IsFlashOn = false; }} And {return; }} @ Override Public Wide Successful Switch (Surface holder holder, int format, int width, intensity height) {/ TODO Auto-Generated Method Stub} @ Override Public Wide Propracted (Surface Holder) {// Tudo Auto-Generated Melt Stub mHolder = holder; {Try Cam.setPreviewDisplay (mHolder); } Grip (IOException E) {// TODO Auto-Generated Catch Block e.printStackTrace (); }} @ Override public zero surface deletion (surface holder) {// TODO auto generated method stub camera. Stop preview (); MHolder = Faucet; } Private final Rnnebl mRunnable = new Rnnabl () {public void run () (if (Maktiv) {if (mSwap) {flashLightOn (); Mswap = false; MHander.postDelayed (mRunnable, strobeOnDelay);} Else {flashLightOff () ; MySQL implementation; SurfaceHolder.Clallback   

run method calls the operation of delay with certain parameters means that delay everything else delay on computer Processing of the duration will take time. In your code "B Everything "may seem small and fast, but it will also work with all other processes that are competing for processor time etc.

Your code following simple:

  Lupfrvevr do some processing to turn off the light, delayed for a certain time; EndLoop  

There is a normal way of dealing with routine activities like: < / P>

  LOOP FRWWARE light Turn or do some processing to stop; Calculate time interval in search of next toggle delay for calculation interval; EndLoop  

Note that when calculating the intervals will be time-per-clock watch and time now code> time desired . In such a way, a loop can be executed faster than any other. The code always works as to what time the next toggle wants and waits till then. Therefore, the rates should be correct in the long run, although individual running and closing times may be a bit wrong.


Comments

Popular posts from this blog

ios - How do I use CFArrayRef in Swift? -

eclipse plugin - Run java code error: Workspace is closed -

c - Error on building source code in VC 6 -