检查设备有一个摄像头? [英] Check if device has a camera?
本文介绍了检查设备有一个摄像头?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在我的应用程序,我想用相机,如果设备有一个。是否有运行Android的的的任何设备不的有一个摄像头?通过包括以下到我的清单:
In my app, I'd like to use the camera, if the device has one. Are there any devices running android that do not have a camera? By including the following into my manifest:
<uses-feature android:name="android.hardware.camera" android:required="false"/>
然后它基本上说:我会用相机如果存在,但并不需要一个运行应用程序。
then it's basically saying "I'll use a camera if one exists, but don't need one to run the app".
怎么能检查是否存在摄像头的设备上,试图用相机前级?
How could I check if a camera exists on the device, before attempting to use the Camera class?
推荐答案
我还没有尝试过,但是:
I've not tried it, but:
private android.hardware.Camera mCameraDevice;
try {
mCameraDevice = android.hardware.Camera.open();
} catch (RuntimeException e) {
Log.e(TAG, "fail to connect Camera", e);
// Throw exception
}
可能是你所需要的。
May be what you need.
这篇关于检查设备有一个摄像头?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文