1

I have developed a code to open the flashlight in android phones with torch mode. I don't know if torch mode is not supported in Motorola razor but it does works on Motorola g. My question actually is..

1) If you could provide me a way so i could read and according to what a phone supports change my code for them to open flash

2)How should i change my code so it'll be supported by the razor.

private void turnOnFlash() {
       if (!isFlashOn) {
           if (camera == null || params == null) {
               return;
           }
           // play sound
          // playSound();
           try { 
           params = camera.getParameters();
           params.setFlashMode(Parameters.FLASH_MODE_TORCH);
           camera.setParameters(params);
           camera.startPreview();
           isFlashOn = true;
           }catch (RuntimeException e) {
            }
       }

   }

Should i add something like that?

List<String> flashModes = params.getSupportedFlashModes();
       if (flashModes.contains(android.hardware.Camera.Parameters.FLASH_MODE_AUTO))
       {
            params.setFlashMode(Parameters.FLASH_MODE_AUTO);
       }
We're All Mad Here
  • 1,544
  • 3
  • 18
  • 46
  • Should i do like so: [Possible answer to this question.](http://stackoverflow.com/questions/21674345/opening-flashlight-in-android-with-different-modes) Even so i am not sure if it works, that's why it is posted as a question. – We're All Mad Here Feb 10 '14 at 11:36

0 Answers0