Skip to content

Instantly share code, notes, and snippets.

@DavidTPate
Created February 13, 2013 04:49
Show Gist options
  • Save DavidTPate/4942380 to your computer and use it in GitHub Desktop.
Save DavidTPate/4942380 to your computer and use it in GitHub Desktop.
private Camera getCameraInstance() {
try {
// attempt to get a Camera instance
// this will open the default camera, which is the back-facing camera (if it exists)
mCamera = Camera.open();
// need to handle the Media Server Dying
mCamera.setErrorCallback(getErrorCallback());
Log.d(TAG, "Camera Opened Successfully");
} catch (RuntimeException e) {
Log.d(TAG, "Failed to Open Camera - " + e.getMessage());
// Camera is not available (in use or does not exist)
}
return mCamera; // returns null if camera is unavailable
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment