Skip to content

Instantly share code, notes, and snippets.

@DavidTPate
Created February 13, 2013 04:49
Show Gist options
  • Select an option

  • Save DavidTPate/4942383 to your computer and use it in GitHub Desktop.

Select an option

Save DavidTPate/4942383 to your computer and use it in GitHub Desktop.
private void deinitialize() {
stopPreview();
releaseCamera();
Log.d(TAG, "Camera Initialization has Been Undone");
}
private void initialize() {
if (hasCamera(this) && getCameraInstance() != null) {
startPreview();
Log.d(TAG, "Camera Initialization has Been Completed");
}
}
private void releaseCamera() {
if (mCamera != null) {
mCamera.release();
mCamera = null;
Log.d(TAG, "Camera Released");
}
}
private void startPreview() {
if (mCamera != null) {
mCameraPreview = new SimpleCameraPreview(this, mCamera);
FrameLayout preview = (FrameLayout) findViewById(R.id.camera_preview);
preview.addView(mCameraPreview);
Log.d(TAG, "Preview Started");
}
}
private void stopPreview() {
if (mCamera != null)
mCamera.stopPreview();
mCameraPreview = null;
Log.d(TAG, "Preview Stopped");
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment