how to check if device has flash light led android

前端 未结 5 909
旧巷少年郎
旧巷少年郎 2020-12-10 01:36

How can I check if a device has a camera led (flashlight). I am talking about devices with android OS?

I have seen solutions some solutions which talks about how to

5条回答
  •  半阙折子戏
    2020-12-10 01:53

    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.

提交回复
热议问题