title: SOS flashlight - How to
body: <p>I made a flashlight app and now I want to add sos morse code flashing. This is my code for it but it doesen't work quite well, it blinks too fast so I need some kind of a delay, can anyone help?</p>
  
  <pre><code>public void sos(View v) {
      String myString = "111000111";
      Handler handler = new Handler();
  
  
      for (int x = 0; x &lt; myString.length(); x++) {
          if (myString.charAt(x) == '1') {
              handler.postDelayed(new Runnable() {
                  public void run() {
                      params.setFlashMode(Camera.Parameters.FLASH_MODE_TORCH);
                      camera.setParameters(params);
                      camera.startPreview();
                  }
              }, 300);
  
  
              handler.postDelayed(new Runnable() {
                  public void run() {
                      params.setFlashMode(Camera.Parameters.FLASH_MODE_OFF);
                      camera.setParameters(params);
                   }
              }, 300);
  
  
              handler.postDelayed(new Runnable() {
                  public void run() {
                      params.setFlashMode(Camera.Parameters.FLASH_MODE_OFF);
                      camera.setParameters(params);
                  }
              }, 300);
  
          }
  
      }
  }
  </code></pre>