Android
android.hardware
public class

android.hardware.Camera

java.lang.Object
android.hardware.Camera

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 Classes
Camera.AutoFocusCallback Handles the callback for the camera auto focus. 
Camera.ErrorCallback Handles the camera error callback. 
Camera.Parameters Handles the parameters for pictures created by a Camera service. 
Camera.PictureCallback Handles the callback for when a picture is taken. 
Camera.PreviewCallback Used to get a copy of each preview frame. 
Camera.Size Handles the picture size (dimensions). 

Summary

Constants

      Value  
int  CAMERA_ERROR_SERVER_DIED  Media server died.  100  0x00000064 
int  CAMERA_ERROR_UNKNOWN  Unspecified camerar error.  0x00000001 

Public Methods

    final      void  autoFocus(Camera.AutoFocusCallback cb)
Registers a callback to be invoked when the auto focus responds.
          Camera.Parameters  getParameters()
Returns the picture Parameters for this Camera service.
      static    Camera  open()
Returns a new Camera object.
    final      void  release()
Disconnects and releases the Camera object resources.
    final      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.
    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.
    final      void  setPreviewDisplay(SurfaceHolder holder)
Sets the SurfaceHolder to be used for a picture preview.
    final      void  startPreview()
Start drawing preview frames to the surface.
    final      void  stopPreview()
Stop drawing preview frames to the surface.
    final      void  takePicture(Camera.PictureCallback raw, Camera.PictureCallback jpeg)
Registers a callback to be invoked when a picture is taken.

Protected Methods

          void  finalize()
Called by the virtual machine when there are no longer any (non-weak) references to the receiver.
Methods inherited from class java.lang.Object

Details

Constants

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
Constant Value: 100 (0x00000064)

public static final int CAMERA_ERROR_UNKNOWN

Unspecified camerar error. @see #ErrorCallback
Constant Value: 1 (0x00000001)

Public Methods

public final void autoFocus(Camera.AutoFocusCallback cb)

Registers a callback to be invoked when the auto focus responds.

Parameters

cb the callback to run

public Camera.Parameters getParameters()

Returns the picture Parameters for this Camera service.

public static Camera open()

Returns a new Camera object.

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.

public final void setErrorCallback(Camera.ErrorCallback cb)

Registers a callback to be invoked when an error occurs.

Parameters

cb the callback to run

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

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.

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

public final void startPreview()

Start drawing preview frames to the surface.

public final void stopPreview()

Stop drawing preview frames to the surface.

public final void takePicture(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

Protected Methods

protected void finalize()

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.

Copyright 2007 Google Inc. Build 0.9_r1-98467 - 14 Aug 2008 18:48