Build 1.0_r1(from source)

android.hardware
Class Camera

java.lang.Object
  extended by android.hardware.Camera

public class Camera
extends Object

The Camera class is used to connect/disconnect with the camera service, set capture settings, start/stop preview, snap a picture, and retrieve frames for encoding for video.

There is no default constructor for this class. Use open() to get a Camera object.


Nested Class Summary
static interface Camera.AutoFocusCallback
          Handles the callback for the camera auto focus.
static interface Camera.ErrorCallback
          Handles the camera error callback.
 class Camera.Parameters
          Handles the parameters for pictures created by a Camera service.
static interface Camera.PictureCallback
          Handles the callback for when a picture is taken.
static interface Camera.PreviewCallback
          Used to get a copy of each preview frame.
static interface Camera.ShutterCallback
          An interface which contains a callback for the shutter closing after taking a picture.
 class Camera.Size
          Handles the picture size (dimensions).
 
Field Summary
static int CAMERA_ERROR_SERVER_DIED
          Media server died.
static int CAMERA_ERROR_UNKNOWN
          Unspecified camerar error.
 
Constructor Summary
Camera()
           
 
Method Summary
 void autoFocus(Camera.AutoFocusCallback cb)
          Registers a callback to be invoked when the auto focus responds.
protected  void finalize()
          Called by the virtual machine when there are no longer any (non-weak) references to the receiver.
 Camera.Parameters getParameters()
          Returns the picture Parameters for this Camera service.
static Camera open()
          Returns a new Camera object.
 void release()
          Disconnects and releases the Camera object resources.
 void setErrorCallback(Camera.ErrorCallback cb)
          Registers a callback to be invoked when an error occurs.
 void setParameters(Camera.Parameters params)
          Sets the Parameters for pictures from this Camera service.
 void setPreviewCallback(Camera.PreviewCallback cb)
          Can be called at any time to instruct the camera to use a callback for each preview frame in addition to displaying it.
 void setPreviewDisplay(SurfaceHolder holder)
          Sets the SurfaceHolder to be used for a picture preview.
 void startPreview()
          Start drawing preview frames to the surface.
 void stopPreview()
          Stop drawing preview frames to the surface.
 void takePicture(Camera.ShutterCallback shutter, Camera.PictureCallback raw, Camera.PictureCallback jpeg)
          Registers a callback to be invoked when a picture is taken.
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

CAMERA_ERROR_UNKNOWN

public static final int CAMERA_ERROR_UNKNOWN
Unspecified camerar error. @see #ErrorCallback

See Also:
Constant Field Values

CAMERA_ERROR_SERVER_DIED

public static final int CAMERA_ERROR_SERVER_DIED
Media server died. In this case, the application must release the Camera object and instantiate a new one. @see #ErrorCallback

See Also:
Constant Field Values
Constructor Detail

Camera

Camera()
Method Detail

open

public static Camera open()
Returns a new Camera object.


finalize

protected void finalize()
Description copied from class: Object
Called by the virtual machine when there are no longer any (non-weak) references to the receiver. Subclasses can use this facility to guarantee that any associated resources are cleaned up before the receiver is garbage collected. Uncaught exceptions which are thrown during the running of the method cause it to terminate immediately, but are otherwise ignored.

Note: The virtual machine assumes that the implementation in class Object is empty.

Overrides:
finalize in class Object

release

public final void release()
Disconnects and releases the Camera object resources.

It is recommended that you call this as soon as you're done with the Camera object.


setPreviewDisplay

public final void setPreviewDisplay(SurfaceHolder holder)
Sets the SurfaceHolder to be used for a picture preview. If the surface changed since the last call, the screen will blank. Nothing happens if the same surface is re-set.

Parameters:
holder - the SurfaceHolder upon which to place the picture preview

startPreview

public final void startPreview()
Start drawing preview frames to the surface.


stopPreview

public final void stopPreview()
Stop drawing preview frames to the surface.


setPreviewCallback

public final void setPreviewCallback(Camera.PreviewCallback cb)
Can be called at any time to instruct the camera to use a callback for each preview frame in addition to displaying it.

Parameters:
cb - A callback object that receives a copy of each preview frame. Pass null to stop receiving callbacks at any time.

autoFocus

public final void autoFocus(Camera.AutoFocusCallback cb)
Registers a callback to be invoked when the auto focus responds.

Parameters:
cb - the callback to run

takePicture

public final void takePicture(Camera.ShutterCallback shutter,
                              Camera.PictureCallback raw,
                              Camera.PictureCallback jpeg)
Registers a callback to be invoked when a picture is taken.

Parameters:
raw - the callback to run for raw images, may be null
jpeg - the callback to run for jpeg images, may be null

setErrorCallback

public final void setErrorCallback(Camera.ErrorCallback cb)
Registers a callback to be invoked when an error occurs.

Parameters:
cb - the callback to run

setParameters

public void setParameters(Camera.Parameters params)
Sets the Parameters for pictures from this Camera service.

Parameters:
params - the Parameters to use for this Camera service

getParameters

public Camera.Parameters getParameters()
Returns the picture Parameters for this Camera service.


Build 1.0_r1(from source)

Please submit a feedback, bug or feature