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.ShutterCallback | An interface which contains a callback for the shutter closing after taking a picture. | ||||||||||
Camera.Size | Handles the picture size (dimensions). |
Constants | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
int | CAMERA_ERROR_SERVER_DIED | Media server died. | |||||||||
int | CAMERA_ERROR_UNKNOWN | Unspecified camerar error. |
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Starts auto-focus function and registers a callback function to
run when camera is focused.
| |||||||||||
Returns the picture Parameters for this Camera service.
| |||||||||||
Returns a new Camera object.
| |||||||||||
Disconnects and releases the Camera object resources.
| |||||||||||
Registers a callback to be invoked when an error occurs.
| |||||||||||
Installs a callback to retrieve a single preview frame, after which the
callback is cleared.
| |||||||||||
Sets the Parameters for pictures from this Camera service.
| |||||||||||
Can be called at any time to instruct the camera to use a callback for
each preview frame in addition to displaying it.
| |||||||||||
Sets the SurfaceHolder to be used for a picture preview.
| |||||||||||
Start drawing preview frames to the surface.
| |||||||||||
Stop drawing preview frames to the surface.
| |||||||||||
Triggers an asynchronous image capture.
|
Protected Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Is called before the object's memory is being reclaimed by the VM.
|
[Expand]
Inherited Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
From class java.lang.Object
|
Media server died. In this case, the application must release the Camera object and instantiate a new one. @see #ErrorCallback
Unspecified camerar error. @see #ErrorCallback
Starts auto-focus function and registers a callback function to run when camera is focused. Only valid after startPreview() has been called.
cb | the callback to run |
---|
Returns the picture Parameters for this Camera service.
Returns a new Camera object.
Disconnects and releases the Camera object resources.
It is recommended that you call this as soon as you're done with the Camera object.
Registers a callback to be invoked when an error occurs.
cb | the callback to run |
---|
Installs a callback to retrieve a single preview frame, after which the callback is cleared.
cb | A callback object that receives a copy of the preview frame. |
---|
Sets the Parameters for pictures from this Camera service.
params | the Parameters to use for this Camera service |
---|
Can be called at any time to instruct the camera to use a callback for each preview frame in addition to displaying it.
cb | A callback object that receives a copy of each preview frame. Pass null to stop receiving callbacks at any time. |
---|
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.
holder | the SurfaceHolder upon which to place the picture preview |
---|
IOException | if the method fails. |
---|
Start drawing preview frames to the surface.
Stop drawing preview frames to the surface.
Triggers an asynchronous image capture. The camera service will initiate a series of callbacks to the application as the image capture progresses. The shutter callback occurs after the image is captured. This can be used to trigger a sound to let the user know that image has been captured. The raw callback occurs when the raw image data is available. The jpeg callback occurs when the compressed image is available. If the application does not need a particular callback, a null can be passed instead of a callback method.
shutter | callback after the image is captured, may be null |
---|---|
raw | callback with raw image data, may be null |
jpeg | callback with jpeg image data, may be null |
Is called before the object's memory is being reclaimed by the VM. This can only happen once the VM has detected, during a run of the garbage collector, that the object is no longer reachable by any thread of the running application.
The method can be used to free system resources or perform other cleanup
before the object is garbage collected. The default implementation of the
method is empty, which is also expected by the VM, but subclasses can
override finalize()
as required. Uncaught exceptions which are
thrown during the execution of this method cause it to terminate
immediately but are otherwise ignored.
Note that the VM does guarantee that finalize()
is called at most
once for any object, but it doesn't guarantee when (if at all) finalize()
will be called. For example, object B's finalize()
can delay the execution of object A's finalize()
method and
therefore it can delay the reclamation of A's memory. To be safe, use a
ReferenceQueue, because it provides more control
over the way the VM deals with references during garbage collection.