Android的前置摄像头 [英] Android front camera
问题描述
我需要一个函数来检查前置摄像头的存在,如果是的话 - 显示preVIEW。 我发现了一些联系,但他们每个人谈论的特定设备:
I need ONE function to check if front camera exist, and if so - show preview. I found a few links, but each of them talk about a specific device:
- 如何打开"前置摄像头" Android平台?
- <一个href="http://developer.android.com/reference/android/hardware/Camera.html#open(int">http://developer.android.com/reference/android/hardware/Camera.html#open(int
- <一个href="http://stackoverflow.com/questions/5673725/front-facing-camera-on-lg-optimus-2x-speed">Front-facing相机LG擎天柱2X速度
- <一个href="http://stackoverflow.com/questions/4241292/how-to-use-front-facing-camera-on-samsung-galaxy-s">How使用前置摄像头的三星Galaxy S
- How to open "front camera" on android platform?
- http://developer.android.com/reference/android/hardware/Camera.html#open(int
- Front-facing camera on LG Optimus 2X Speed
- How to use Front Facing Camera on Samsung Galaxy S
任何人都可以提供一个通用的code这个?或者,也许一个组合code,将所有设备的工作?
Can anyone provide a generic code for this? Or maybe a combined code that will work with all devices?
推荐答案
原料药> = 9 ,您可以使用摄像机
类: <一href="http://developer.android.com/reference/android/hardware/Camera.html">http://developer.android.com/reference/android/hardware/Camera.html看它是否有一个以上的摄像头,并查询 CameraInfo
For APIs >=9, you can use the Camera
class: http://developer.android.com/reference/android/hardware/Camera.html to see if it has more than one camera, and query the CameraInfo
-
getNumberOfCameras
getCameraInfo
:
<一个href="http://developer.android.com/reference/android/hardware/Camera.CameraInfo.html">http://developer.android.com/reference/android/hardware/Camera.CameraInfo.html
常量
INT CAMERA_FACING_BACK摄像机的衬面是相反的屏幕的
int CAMERA_FACING_BACK The facing of the camera is opposite to that of the screen.
INT CAMERA_FACING_FRONT摄像机的朝向是相同的画面。
int CAMERA_FACING_FRONT The facing of the camera is the same as that of the screen.
原料药> = 5 ,一个选择是读公开名单&LT; Camera.Size&GT; getSupportedPictureSizes()
。前置摄像头通常会低得多最大分辨率比回相机。
For APIs >=5, an option is to read public List<Camera.Size> getSupportedPictureSizes ()
. Front facing cameras will usually have much lower max resolution than back cameras.
<一个href="http://developer.android.com/reference/android/hardware/Camera.Parameters.html">http://developer.android.com/reference/android/hardware/Camera.Parameters.html
这篇关于Android的前置摄像头的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!