本文介绍了Android的前置摄像头的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要一个函数来检查前置摄像头的存在,如果是的话 - 显示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:

  • 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 ,您可以使用摄像机类: 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

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 ,一个选择是读公开名单< Camera.Size> 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.

http://developer.android.com/reference/android/hardware/Camera.Parameters.html

这篇关于Android的前置摄像头的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-25 17:33