Java tutorial
//package com.java2s; //License from project: Open Source License import java.lang.reflect.Method; import android.hardware.Camera; public class Main { /** Opens the camera with the given ID. If the Android API doesn't support multiple cameras (i.e. prior to Android 2.3), * always opens the primary camera. */ public static Camera openCamera(int cameraId) { if (cameraId >= 0) { Method openMethod = null; try { openMethod = Camera.class.getMethod("open", int.class); } catch (Exception ex) { openMethod = null; } if (openMethod != null) { try { return (Camera) openMethod.invoke(null, cameraId); } catch (Exception ignored) { } } } return Camera.open(); } }