安卓:确定摄像机的数量上2.2及以上 [英] Android: Determining number of cameras on 2.2 and above

查看:107
本文介绍了安卓:确定摄像机的数量上2.2及以上的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的应用程序需要在Android 2.2及以上运行。我需要一种方法来确定可用的摄像头数量。还有一些帖子解决这个问题的,但我无法找到一个工作。

My app needs to run on Android 2.2 and above. I need a way to determine the number of cameras available. There are a number of posts addressing this but I couldn't find one that works.

一个简单的办法就是检测操作系统版本和任何与2.2将只限于1摄像机(即使该设备确实有2个),但我还是没有办法搞清楚摄像机的数量更大的任何版本大于2.2。

One solution is simply to detect the OS version and anything with 2.2 would only be limited to 1 camera (even if the device really did have 2) but I still have no way of figuring out the number of cameras for any versions greater than 2.2.

推荐答案

多个摄像头,不支持较早的操作系统版本,所以你可以假设,即使该设备有2个,它们不支持标准的Andr​​oid你有1 API。对于较新版本的操作系统,只需要使用 Camera.getNumberOfCameras() Camera.getCameraInfo()与API级别后卫声明:

Multiple cameras are not supported on earlier OS versions, so you can just assume you have 1. even the device had 2, they are not supported by the standard Android API. For newer OS versions, just use the Camera.getNumberOfCameras() and Camera.getCameraInfo() with an API level guard statement:

 int numCameras = 1;
 if (Build.Version.SDK_INT >= Build.VERSION_CODES.GINGERBREAD) {
   numCameras = Camera.getNumberOfCameras();
 }

这篇关于安卓:确定摄像机的数量上2.2及以上的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆