How To Find Flashlight Feature Is Available Or Not In Device < = Sdk 4
I used to find the flashlight is available or not using this code context.getPackageManager().hasSystemFeature(PackageManager.FEATURE_CAMERA_FLASH); but this code is support for s
Solution 1:
Android SDK has Camera class.. you can try getFlashMode method .. If method return null then flash is not support...
http://developer.android.com/reference/android/hardware/Camera.Parameters.html#getFlashMode()
I have not tried it,
Solution 2:
Try this:
public boolean hasFlash() {
if (camera == null) {
returnfalse;
}
Camera.Parameters parameters = camera.getParameters();
if (parameters.getFlashMode() == null) {
returnfalse;
}
List<String> supportedFlashModes = parameters.getSupportedFlashModes();
if (supportedFlashModes == null || supportedFlashModes.isEmpty() || supportedFlashModes.size() == 1 && supportedFlashModes.get(0).equals(Camera.Parameters.FLASH_MODE_OFF)) {
returnfalse;
}
returntrue;
}
Post a Comment for "How To Find Flashlight Feature Is Available Or Not In Device < = Sdk 4"