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

前端 未结 4 486
一生所求
一生所求 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:53

    You can use the following

    context.getPackageManager().hasSystemFeature(PackageManager.FEATURE_CAMERA_FLASH);
    

    which will return true if a flash is available, false if not.

    See http://developer.android.com/reference/android/content/pm/PackageManager.html for more information.

提交回复
热议问题