CodeDocu.com

Android code for turning on and OFF two timers

 

Code example:

The Android Java code generates a pulse signal as a changing ON and OFF switch of the flashlight in the phone. So something like a Strobo-Effect lamp.

 

Android code for turning on and OFF two timers

 

Timer Code , android Smartphone

public void start_flash_Impule_HIGH()
{
   
//----< start_flash_Impule_HIGH() >----
    //< check >
   
if (!_toggleButton.isChecked()) return;
   
if (!_switchImpuler.isChecked()) return;


   
Timer _timerPulsHIGH = new Timer();
   
_timerPulsHIGH.schedule(new TimerTask() {
       
@Override
       
public void run()
        {
           
try {
               
_flashIsOn = true;
               
_CameraManager.setTorchMode(_CameraId, true);
                start_flash_Impule_LOW();

            }
           
catch (CameraAccessException e) {
                e.printStackTrace();
            }
        }
    },
_milliSedonds_LOW);
   
//----</ Pstart_flash_Impule_HIGH() >--

}

public void start_flash_Impule_LOW()
{
   
//----< start_flash_Impule_LOW() >----
   
Timer _timerPulsLOW = new Timer();
   
_timerPulsLOW.schedule(new TimerTask() {
       
@Override
       
public void run()
        {
           
try {
               
_flashIsOn = false;
                
_CameraManager.setTorchMode(_CameraId, false);
                start_flash_Impule_HIGH();

            }
           
catch (CameraAccessException e) {
                e.printStackTrace();
            }

        }
    },
_milliSeconds_HIGH);

   
//----</ start_flash_Impule_LOW() >--

}

 

 

 

 


Software Entwicklung Stuttgart NĂ¼rtingen
Suche Projekte C#, WPF, Windows App,ASP.Net, vb.Net, WinForms, SQL Server, Access, Excel