Android examples for android.hardware:Camera State
get Camera Facing Intent Extras
import com.android.camera.CameraHolder; import android.app.Activity; public class Main{ private static final String EXTRAS_CAMERA_FACING = "android.intent.extras.CAMERA_FACING"; public static int getCameraFacingIntentExtras(Activity currentActivity) { int cameraId = -1; int intentCameraId = currentActivity.getIntent().getIntExtra(EXTRAS_CAMERA_FACING, -1); if (isFrontCameraIntent(intentCameraId)) { // Check if the front camera exist int frontCameraId = CameraHolder.instance().getFrontCameraId(); if (frontCameraId != -1) { cameraId = frontCameraId; }/* w ww. j av a2 s . c om*/ } else if (isBackCameraIntent(intentCameraId)) { // Check if the back camera exist int backCameraId = CameraHolder.instance().getBackCameraId(); if (backCameraId != -1) { cameraId = backCameraId; } } return cameraId; } private static boolean isBackCameraIntent(int intentCameraId) { return (intentCameraId == android.hardware.Camera.CameraInfo.CAMERA_FACING_BACK); } private static boolean isFrontCameraIntent(int intentCameraId) { return (intentCameraId == android.hardware.Camera.CameraInfo.CAMERA_FACING_FRONT); } }