Android: how to check the flash light is available on device?

前端 未结 4 514
一生所求
一生所求 2021-01-18 10:27

How I check the flash light available on device?also want to know how can I On/Off the flash light? I have put the code but not working right now? I search out this

4条回答
  •  既然无缘
    2021-01-18 10:40

    First you get supported flash modes:

    camera = Camera.open(i);    // Introduced in API level 9
    parameters = camera.getParameters();
    String[] flashModes = parameters.getSupportedFlashModes();
    

    And then you check if this array contains the correct constants like: "auto", "on", "off".

    More info in: http://developer.android.com/reference/android/hardware/Camera.Parameters.html#FLASH_MODE_AUTO

提交回复
热议问题