how to check if device has flash light led android

The other answers

boolean hasFlash = this.getPackageManager().hasSystemFeature(PackageManager.FEATURE_CAMERA_FLASH);

Does not work for the new 2013 Nexus 7. The following code will work:

public boolean hasFlash() {
        if (camera == null) {
            return false;
        }

        Camera.Parameters parameters;
        try {
            parameters = camera.getParameters();
        } catch (RuntimeException ignored)  {
            return false;
        }

        if (parameters.getFlashMode() == null) {
            return false;
        }

        List<String> supportedFlashModes = parameters.getSupportedFlashModes();
        if (supportedFlashModes == null || supportedFlashModes.isEmpty() || supportedFlashModes.size() == 1 && supportedFlashModes.get(0).equals(Camera.Parameters.FLASH_MODE_OFF)) {
            return false;
        }

        return true;
    }

getPackageManager().hasSystemFeature(PackageManager.FEATURE_CAMERA_FLASH) returns true if the device has flash. See this for more details


You should be able to check whether the flash is available by checking system features:

boolean hasFlash = this.getPackageManager()
                       .hasSystemFeature(PackageManager.FEATURE_CAMERA_FLASH);

(provided you are in an Activity). If not, than use some sort of context in place of this.

P.S. Note that this information is quite easy to find if you actually try searching for it.