Android examples for Camera:Camera Attribute
A safe way to get an instance of the Camera object.
//package com.java2s; import android.hardware.Camera; import android.util.Log; public class Main { /** A safe way to get an instance of the Camera object. */ public static Camera getCameraInstance() { Camera c = null;/*from ww w .j av a 2 s. c o m*/ try { c = Camera.open(); // attempt to get a Camera instance } catch (Exception e) { // Camera is not available (in use or does not exist) Log.e("ch.getCI", "Failed to get camera!", e); } return c; // returns null if camera is unavailable } }