如何检查设备已闪光灯导致的android [英] how to check if device has flash light led android
本文介绍了如何检查设备已闪光灯导致的android的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我如何检查如果设备有一个摄像头LED(手电筒)。我说的是采用Android操作系统的设备?
How can I check if a device has a camera led (flashlight). I am talking about devices with android OS?
我已经看到了一些解决方案,解决方案,谈论如何打开和关闭LED,但如果设备没有,甚至有一个领导会发生什么。
I have seen solutions some solutions which talks about how to turn the led on and off but what will happen if the device doesn't even has a led.
车削我使用的是相机 camera.open()
推荐答案
其他答案
boolean hasFlash = this.getPackageManager().hasSystemFeature(PackageManager.FEATURE_CAMERA_FLASH);
新的Nexus 2013 7.下列code将工作不工作:
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 = camera.getParameters();
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;
}
这篇关于如何检查设备已闪光灯导致的android的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文