List of usage examples for android.hardware Camera getNumberOfCameras
public native static int getNumberOfCameras();
From source file:Main.java
public static int getFrontCameraId() { int cameraCount = 0; Camera.CameraInfo cameraInfo = new Camera.CameraInfo(); cameraCount = Camera.getNumberOfCameras(); for (int camIdx = 0; camIdx < cameraCount; camIdx++) { Camera.getCameraInfo(camIdx, cameraInfo); if (cameraInfo.facing == Camera.CameraInfo.CAMERA_FACING_FRONT) { return camIdx; }//from w w w .jav a2 s. c o m } return -1; }
From source file:Main.java
public static boolean hasCamera() { final int cameraCount = Camera.getNumberOfCameras(); Camera.CameraInfo info = new Camera.CameraInfo(); for (int i = 0; i < cameraCount; i++) { Camera.getCameraInfo(i, info);//w w w .java2s .c o m if (info.facing == CAMERA_FACING_BACK) { return true; } } return false; }
From source file:Main.java
public static int getNumberOfCameras() { int cameraNumber = 1; if (Build.VERSION.SDK_INT >= 9) { cameraNumber = Camera.getNumberOfCameras(); }//from w w w .j a va 2 s . c om return cameraNumber; }
From source file:Main.java
public static int HasBackCamera() { int numberOfCameras = Camera.getNumberOfCameras(); CameraInfo cameraInfo = new CameraInfo(); for (int i = 0; i < numberOfCameras; i++) { Camera.getCameraInfo(i, cameraInfo); if (cameraInfo.facing == CAMERA_FACING_BACK) { return i; }//from ww w . ja v a 2s . com } return 2; }
From source file:Main.java
public static int HasFrontCamera() { int numberOfCameras = Camera.getNumberOfCameras(); CameraInfo cameraInfo = new CameraInfo(); for (int i = 0; i < numberOfCameras; i++) { Camera.getCameraInfo(i, cameraInfo); if (cameraInfo.facing == CAMERA_FACING_FRONT) { return i; }/*from w w w. jav a 2s.co m*/ } return 2; }
From source file:Main.java
static int getCameraId(int position) { // Find the total number of cameras available int mNumberOfCameras = Camera.getNumberOfCameras(); // Find the ID of the back-facing ("default") camera Camera.CameraInfo cameraInfo = new Camera.CameraInfo(); for (int i = 0; i < mNumberOfCameras; i++) { Camera.getCameraInfo(i, cameraInfo); if (cameraInfo.facing == position) return i; }// w w w . j a va2s . co m return NO_CAMERA; }
From source file:Main.java
public static boolean hasFrontCamera() { for (int i = 0; i < Camera.getNumberOfCameras(); i++) { Camera.CameraInfo cameraInfo = new Camera.CameraInfo(); Camera.getCameraInfo(i, cameraInfo); if (cameraInfo.facing == Camera.CameraInfo.CAMERA_FACING_FRONT) { return true; }/*w ww . j a v a 2 s. co m*/ } return false; }
From source file:Main.java
public static int findBackFacingCamera() { int cameraId = INVALID_CAMERA_ID; // Search for the front facing camera int numberOfCameras = Camera.getNumberOfCameras(); for (int i = 0; i < numberOfCameras; i++) { Camera.CameraInfo info = new Camera.CameraInfo(); Camera.getCameraInfo(i, info);/*from ww w .ja v a2 s . com*/ if (info.facing == Camera.CameraInfo.CAMERA_FACING_BACK) { Log.d("CameraUtil", "Camera found"); cameraId = i; break; } } return cameraId; }
From source file:Main.java
public static int findFrontFacingCamera() { int cameraId = INVALID_CAMERA_ID; // Search for the front facing camera int numberOfCameras = Camera.getNumberOfCameras(); for (int i = 0; i < numberOfCameras; i++) { Camera.CameraInfo info = new Camera.CameraInfo(); Camera.getCameraInfo(i, info);/*from ww w . j a v a2s . com*/ if (info.facing == Camera.CameraInfo.CAMERA_FACING_FRONT) { Log.d("CameraUtil", "Camera found"); cameraId = i; break; } } return cameraId; }
From source file:Main.java
/** * @return front camera//from w w w. j a v a2 s . com */ public static Camera getFrontCamera() { CameraInfo cameraInfo = new CameraInfo(); int cameraCount = Camera.getNumberOfCameras(); for (int i = 0; i < cameraCount; i++) { Camera.getCameraInfo(i, cameraInfo); if (cameraInfo.facing == Camera.CameraInfo.CAMERA_FACING_FRONT) { cameraId = i; return Camera.open(i); } } return null; }