Step 1)
Add the below permission to manifest.xml
Check programmatically the availability of flashlight in device .
Step 3)
Turn on camera flash light LED.
Turn off camera flash light LED.
Add the below permission to manifest.xml
<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.FLASHLIGHT"/>
Step 2)Check programmatically the availability of flashlight in device .
context.getPackageManager().hasSystemFeature(PackageManager.FEATURE_CAMERA_FLASH);
It returns true if flash is available .Step 3)
Turn on camera flash light LED.
Camera cam = Camera.open();
Parameters p = cam.getParameters();
p.setFlashMode(Parameters.FLASH_MODE_TORCH);
cam.setParameters(p);
cam.startPreview();
Step 4)Turn off camera flash light LED.
cam.stopPreview();
cam.release();
No comments:
Post a Comment