#

Android Code zum AN und AUS Schalten zweier Timer

 

Code Beispiel:

Die Android Java Code erzeugt ein Impuls-Signal als wechselnder AN und AUS Schalter der Taschenlampe im Handy. Also sowas wie eine Strobo-Effect Lampe.

 

 

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() >--

}

 

 

 

 

Mobile

.