Android front camera

后端 未结 4 1081
天涯浪人
天涯浪人 2020-11-28 12:13

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 do I open
4条回答
  •  [愿得一人]
    2020-11-28 12:46

    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

    Constants

    int CAMERA_FACING_BACK The facing of the camera is opposite to that of the screen.

    int CAMERA_FACING_FRONT The facing of the camera is the same as that of the screen.


    For APIs >=5, an option is to read public List getSupportedPictureSizes (). Front facing cameras will usually have much lower max resolution than back cameras.

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

提交回复
热议问题