get Camera Type From Id - Android android.hardware

Android examples for android.hardware:Camera ID

Description

get Camera Type From Id

Demo Code

import android.annotation.TargetApi;
import android.hardware.Camera;
import android.hardware.Camera.CameraInfo;
import android.os.Build;

public class Main {

  @TargetApi(Build.VERSION_CODES.GINGERBREAD)
  public static int getCameraTypeFromId(int cameraId) {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.GINGERBREAD) {
      Camera.CameraInfo info = new Camera.CameraInfo();
      Camera.getCameraInfo(cameraId, info);
      return info.facing;
    }/*from  w w w.  ja va 2 s. co  m*/
    /* By default, return that the device has only a rear camera */
    return CameraInfo.CAMERA_FACING_BACK;
  }

}

Related Tutorials