Code example for Camera.Parameters

Methods: getFlashMode, getSupportedFlashModes, setFlashMode

0
    if (parameters == null) {
      // Use the screen as a flashlight (next best thing) 
      button.setBackgroundColor(COLOR_WHITE);
      return; 
    } 
    List<String> flashModes = parameters.getSupportedFlashModes();
    // Check if camera flash exists 
    if (flashModes == null) {
      // Use the screen as a flashlight (next best thing) 
      button.setBackgroundColor(COLOR_WHITE);
      return; 
    } 
    String flashMode = parameters.getFlashMode();
    Log.i(TAG, "Flash mode: " + flashMode);
    Log.i(TAG, "Flash modes: " + flashModes);
    if (!Parameters.FLASH_MODE_TORCH.equals(flashMode)) {
      // Turn on the flash 
      if (flashModes.contains(Parameters.FLASH_MODE_TORCH)) {
        parameters.setFlashMode(Parameters.FLASH_MODE_TORCH);
        mCamera.setParameters(parameters);
        button.setBackgroundColor(COLOR_LIGHT);
        startWakeLock(); 
      } else { 
        Toast.makeText(this, "Flash mode (torch) not supported",