Best code examples for Android Camera class (android.hardware.Camera)

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Android Camera class.
You can now enable Codota on your own code to easily search and navigate your Java codebase.

Android Camera examples from Open Source projects
Examples using Android Camera setPreviewDisplay method:
This code example shows how to use the following methods: setPreviewDisplay, startPreview
43:	mCamera.setPreviewDisplay(holder); 
44:	mCamera.startPreview(); 
Full Snippet Info
10
CodeRank
This code example shows how to use the following methods: setPreviewDisplay
36:	camera.setPreviewDisplay(previewHolder); 
Full Snippet Info
10
CodeRank
This code example shows how to use the following methods: getParameters, setParameters, setPreviewDisplay
38:	Camera.Parameters p = camera.getParameters(); 
-
40:	camera.setParameters(p); 
-
44:	camera.setPreviewDisplay(holder); 
Full Snippet Info
10
CodeRank
Examples using Android Camera getParameters method:
This code example shows how to use the following methods: getParameters, setParameters
135:	mParameters = mCamera.getParameters(); 
-
148:	mCamera.setParameters(mParameters); 
Full Snippet Info
10
CodeRank
This code example shows how to use the following methods: getParameters, stopPreview
194:	mCamera.stopPreview(); 
-
197:	Camera.Parameters p = mCamera.getParameters(); 
Full Snippet Info
10
CodeRank
This code example shows how to use the following methods: getParameters
141:	String focus_mode = camera.getParameters().getFocusMode(); 
Full Snippet Info
10
CodeRank
Examples using Android Camera stopPreview method:
This code example shows how to use the following methods: stopPreview
159:	camera.stopPreview(); 
Full Snippet Info
10
CodeRank
This code example shows how to use the following methods: stopPreview
171:	camera.stopPreview(); 
Full Snippet Info
10
CodeRank
This code example shows how to use the following methods: stopPreview
159:	camera.stopPreview(); 
Full Snippet Info
10
CodeRank
Examples using Android Camera startPreview method:
This code example shows how to use the following methods: startPreview
117:	camera.startPreview(); 
Full Snippet Info
10
CodeRank
This code example shows how to use the following methods: startPreview
205:	camera.startPreview(); 
Full Snippet Info
10
CodeRank
This code example shows how to use the following methods: getParameters, setParameters, setPreviewDisplay, startPreview, stopPreview
63:	mCamera.stopPreview(); 
-
69:	Camera.Parameters parameters = mCamera.getParameters(); 
-
73:	mCamera.setParameters(parameters); 
-
77:	mCamera.setPreviewDisplay(mHolder); 
78:	mCamera.startPreview(); 
Full Snippet Info
10
CodeRank
Examples using Android Camera setDisplayOrientation method:
This code example shows how to use the following methods: getParameters, setDisplayOrientation, setParameters, setPreviewDisplay, startPreview
43:	mCamera.stopPreview(); 
-
47:	Parameters p = mCamera.getParameters(); 
48:	mCamera.setDisplayOrientation(90); 
49:	mCamera.setParameters(p); 
-
57:	mCamera.setPreviewDisplay(mholder); 
58:	mCamera.startPreview(); 
Full Snippet Info
10
CodeRank
This code example shows how to use the following methods: getParameters, setDisplayOrientation, setParameters, setPreviewDisplay, startPreview
89:	mCamera.stopPreview(); 
-
96:	Camera.Parameters parameters = mCamera.getParameters(); 
-
103:	mCamera.setDisplayOrientation(90); 
104:	mCamera.setParameters(parameters); 
105:	mCamera.setPreviewDisplay(holder); 
106:	mCamera.startPreview(); 
Full Snippet Info
10
CodeRank
Examples using Android Camera setParameters method:
This code example shows how to use the following methods: setParameters
149:	mCamera.setParameters(params); 
Full Snippet Info
10
CodeRank
This code example shows how to use the following methods: getParameters, setParameters, setPreviewDisplay, startPreview, stopPreview
253:	camera.stopPreview(); 
-
257:	Camera.Parameters p = camera.getParameters(); 
-
262:	camera.setParameters(p); 
-
264:	camera.setPreviewDisplay(holder); 
265:	camera.startPreview(); 
Full Snippet Info
10
CodeRank
This code example shows how to use the following methods: getParameters, setParameters, setPreviewDisplay, startPreview
185:	Camera.Parameters parameters = mCamera.getParameters(); 
-
189:	mCamera.setParameters(parameters); 
-
207:	mCamera.setPreviewDisplay(mHolder); 
208:	mCamera.startPreview(); 
Full Snippet Info
10
CodeRank
Examples using Android Camera addCallbackBuffer method:
This code example shows how to use the following methods: addCallbackBuffer
63:	mCamera.addCallbackBuffer(data); 
Full Snippet Info
10
CodeRank
Examples for other Android Camera methods:
Related Android Camera Questions & Answers:
Other Android Camera Examples
12:	public class MakePhotoActivity extends Activity {
13:	  private final static String DEBUG_TAG = "MakePhotoActivity";
14:	  private Camera camera;
15:	  private int cameraId = 0;
16:

Read More

17:		ImageButton btnSwitch;
18:	
19:		private Camera camera;
20:		private boolean isFlashOn;
21:		private boolean hasFlash;

Read More

17:		ImageButton btnSwitch;
18:	
19:		private Camera camera;
20:		private boolean isFlashOn;
21:		private boolean hasFlash;

Read More

Camera Class Overview
The Camera class is used to set image capture settings, start/stop preview, snap pictures, and retrieve frames for encoding for video. This class is a client for the Camera service, which manages the actual camera hardware.

To access the device camera, you must declare the CAMERA permission in your Android Manifest. Also be sure to include the manifest element to declare camera features used by your application. For example, if you use the camera and auto-focus feature, your Manifest should include the following:To take pictures with this class, use the following steps:To quickly switch to video recording mode, use these steps:This class is not thread-safe, and is meant for use from one event thread. Most long-running operations (preview, focus, photo capture, etc) happen asynchronously and invoke callbacks as necessary. Callbacks will be invoked on the event thread open(int) was called from. This class's methods must never be called from multiple threads at once.Caution: Different Android-powered devices may have different hardware specifications, such as megapixel ratings and auto-focus capabilities. In order for your application to be compatible with more devices, you should n...
Methods
  • autoFocus
    Starts camera auto-focus and registers a callback function to run when the camera is focused.
  • getParameters
    Returns the current settings for this Camera service.
  • lock
    Re-locks the camera to prevent other processes from accessing it.
  • reconnect
    Reconnects to the camera service after another process used it.
  • release
    Disconnects and releases the Camera object resources.
  • setOneShotPreviewCallback
    Installs a callback to be invoked for the next preview frame in addition to displaying it on the screen.
  • setPreviewCallback
    Installs a callback to be invoked for every preview frame in addition to displaying them on the screen.
  • setPreviewCallbackWithBuffer
    Installs a callback to be invoked for every preview frame, using buffers supplied with addCallbackBuffer(byte[]), in addition to displaying them on the screen.
  • setZoomChangeListener
    Registers a listener to be notified when the zoom value is updated by the camera driver during smooth zoom.
  • startPreview
    Starts capturing and drawing preview frames to the screen.
  • stopPreview
    Stops capturing and drawing preview frames to the surface, and resets the camera for a future call to startPreview().
  • takePicture
    Equivalent to takePicture(shutter, raw, null, jpeg).
  • unlock
    Unlocks the camera to allow another process to access it.