Created
January 23, 2015 19:11
-
-
Save bharath2020/42e95393ced77d30f794 to your computer and use it in GitHub Desktop.
Switch ON / OFF Flash in Android
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public void turnOFF() | |
{ | |
param = cam.getParameters(); | |
param.setFlashMode(Camera.Parameters.FLASH_MODE_OFF); | |
cam.setParameters(param); | |
cam.stopPreview(); | |
cam.release(); | |
cam=null; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Camera cam; | |
public void turnON() | |
{ | |
Camera cam = Camera.open(); | |
Camera.Parameters param = cam.getParameters(); | |
try { | |
cam.setPreviewTexture(new SurfaceTexture(0)); | |
} catch (IOException e) { | |
e.printStackTrace(); | |
} | |
param.setFlashMode(Camera.Parameters.FLASH_MODE_TORCH); | |
cam.setParameters(param); | |
cam.startPreview(); | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment