Android examples for Camera:Open Camera
Opens the camera with the given ID via reflection
//package com.java2s; 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.// ww w . j a v a2s .c o m */ 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(); } }