java.lang.Object | |
↳ | android.hardware.camera2.CameraDevice.StateListener |
A listener for notifications about the state of a camera device.
A listener must be provided to the openCamera(String, CameraDevice.StateListener, Handler)
method to open a camera device.
These events include notifications about the device completing startup (
allowing for createCaptureSession(List
to be called), about device
disconnection or closure, and about unexpected device errors.
Events about the progress of specific CaptureRequests
are provided
through a CameraCaptureSession.CaptureListener
given to the
capture(CaptureRequest, CameraCaptureSession.CaptureListener, Handler)
, captureBurst(List
,
setRepeatingRequest(CaptureRequest, CameraCaptureSession.CaptureListener, Handler)
, or setRepeatingBurst(List
methods.
Constants | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
int | ERROR_CAMERA_DEVICE | An error code that can be reported by onError(CameraDevice, int)
indicating that the camera device has encountered a fatal error. |
|||||||||
int | ERROR_CAMERA_DISABLED | An error code that can be reported by onError(CameraDevice, int)
indicating that the camera device could not be opened due to a device
policy. |
|||||||||
int | ERROR_CAMERA_IN_USE | An error code that can be reported by onError(CameraDevice, int)
indicating that the camera device is in use already. |
|||||||||
int | ERROR_CAMERA_SERVICE | An error code that can be reported by onError(CameraDevice, int)
indicating that the camera service has encountered a fatal error. |
|||||||||
int | ERROR_MAX_CAMERAS_IN_USE | An error code that can be reported by onError(CameraDevice, int)
indicating that the camera device could not be opened
because there are too many other open camera devices. |
Public Constructors | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
This method is deprecated.
Use
onActive(CameraCaptureSession) instead.
| |||||||||||
This method is deprecated.
Use
onConfigured(CameraCaptureSession) instead.
| |||||||||||
The method called when a camera device has been closed with
close() . | |||||||||||
The method called when a camera device is no longer available for
use.
| |||||||||||
The method called when a camera device has encountered a serious error.
| |||||||||||
This method is deprecated.
Use
onReady(CameraCaptureSession) instead.
| |||||||||||
The method called when a camera device has finished opening.
| |||||||||||
This method is deprecated.
Use
onOpened(CameraDevice) instead.
|
[Expand]
Inherited Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
From class
java.lang.Object
|
An error code that can be reported by onError(CameraDevice, int)
indicating that the camera device has encountered a fatal error.
The camera device needs to be re-opened to be used again.
An error code that can be reported by onError(CameraDevice, int)
indicating that the camera device could not be opened due to a device
policy.
An error code that can be reported by onError(CameraDevice, int)
indicating that the camera device is in use already.
This error can be produced when opening the camera fails.
An error code that can be reported by onError(CameraDevice, int)
indicating that the camera service has encountered a fatal error.
The Android device may need to be shut down and restarted to restore camera function, or there may be a persistent hardware problem.
An attempt at recovery may be possible by closing the CameraDevice and the CameraManager, and trying to acquire all resources again from scratch.
An error code that can be reported by onError(CameraDevice, int)
indicating that the camera device could not be opened
because there are too many other open camera devices.
The system-wide limit for number of open cameras has been reached, and more camera devices cannot be opened until previous instances are closed.
This error can be produced when opening the camera fails.
This method is deprecated.
Use onActive(CameraCaptureSession)
instead.
The method called when a camera device begins processing
capture requests
.
This method is deprecated.
Use onConfigured(CameraCaptureSession)
instead.
The method called when a camera device is busy.
The method called when a camera device has been closed with
close()
.
Any attempt to call methods on this CameraDevice in the
future will throw a IllegalStateException
.
The default implementation of this method does nothing.
camera | the camera device that has become closed |
---|
The method called when a camera device is no longer available for use.
This callback may be called instead of onOpened(CameraDevice)
if opening the camera fails.
Any attempt to call methods on this CameraDevice will throw a
CameraAccessException
. The disconnection could be due to a
change in security policy or permissions; the physical disconnection
of a removable camera device; or the camera being needed for a
higher-priority use case.
There may still be capture listener callbacks that are called after this method is called, or new image buffers that are delivered to active outputs.
The default implementation logs a notice to the system log about the disconnection.
You should clean up the camera with close()
after
this happens, as it is not recoverable until opening the camera again
after it becomes available
.
camera | the device that has been disconnected |
---|
The method called when a camera device has encountered a serious error.
This callback may be called instead of onOpened(CameraDevice)
if opening the camera fails.
This indicates a failure of the camera device or camera service in
some way. Any attempt to call methods on this CameraDevice in the
future will throw a CameraAccessException
with the
CAMERA_ERROR
reason.
There may still be capture completion or camera stream listeners that will be called after this error is received.
You should clean up the camera with close()
after
this happens. Further attempts at recovery are error-code specific.
camera | The device reporting the error |
---|---|
error | The error code, one of the
StateListener.ERROR_* values. |
This method is deprecated.
Use onReady(CameraCaptureSession)
instead.
The method called when a camera device has finished processing all submitted capture requests and has reached an idle state.
The method called when a camera device has finished opening.
At this point, the camera device is ready to use, and
createCaptureSession(List
can be called to set up the first capture
session.
camera | the camera device that has become opened |
---|
This method is deprecated.
Use onOpened(CameraDevice)
instead.
The method called when a camera device has no outputs configured.