public final class CodeScanner
extends java.lang.Object
CodeScannerView,
BarcodeFormat| Modifier and Type | Field and Description |
|---|---|
static java.util.List<BarcodeFormat> |
ALL_FORMATS
All supported barcode formats
|
static int |
CAMERA_BACK
First back-facing camera
|
static int |
CAMERA_FRONT
First front-facing camera
|
static java.util.List<BarcodeFormat> |
ONE_DIMENSIONAL_FORMATS
One dimensional barcode formats
|
static java.util.List<BarcodeFormat> |
TWO_DIMENSIONAL_FORMATS
Two dimensional barcode formats
|
| Constructor and Description |
|---|
CodeScanner(android.content.Context context,
CodeScannerView view)
CodeScanner, associated with the first back-facing camera on the device
|
CodeScanner(android.content.Context context,
CodeScannerView view,
int cameraId)
CodeScanner, associated with particular hardware camera
|
| Modifier and Type | Method and Description |
|---|---|
AutoFocusMode |
getAutoFocusMode()
Get current auto focus mode
|
int |
getCamera()
Get current camera id, or
CAMERA_BACK or CAMERA_FRONT |
DecodeCallback |
getDecodeCallback()
Get current decode callback
|
ErrorCallback |
getErrorCallback()
Get current error callback
|
java.util.List<BarcodeFormat> |
getFormats()
Get current list of formats to decode
|
ScanMode |
getScanMode()
Get current scan mode
|
int |
getZoom()
Get current zoom value
|
boolean |
isAutoFocusEnabled()
Auto focus is currently enabled or not
|
boolean |
isFlashEnabled()
Flash light is currently enabled or not
|
boolean |
isPreviewActive()
Preview is active or not
|
boolean |
isTouchFocusEnabled()
Touch focus is currently enabled or not
|
void |
releaseResources()
Release resources, and stop preview if needed; call this method in
Activity.onPause() |
void |
setAutoFocusEnabled(boolean autoFocusEnabled)
Enable or disable auto focus if it's supported,
true by default |
void |
setAutoFocusInterval(long autoFocusInterval)
Auto focus interval in milliseconds for
AutoFocusMode.SAFE mode, 2000 by default |
void |
setAutoFocusMode(AutoFocusMode autoFocusMode)
Auto focus mode,
AutoFocusMode.SAFE by default |
void |
setCamera(int cameraId)
Camera to use
|
void |
setDecodeCallback(DecodeCallback decodeCallback)
Callback of decoding process
|
void |
setErrorCallback(ErrorCallback errorCallback)
Camera initialization error callback.
|
void |
setFlashEnabled(boolean flashEnabled)
Enable or disable flash light if it's supported,
false by default |
void |
setFormats(java.util.List<BarcodeFormat> formats)
Formats, decoder to react to (
ALL_FORMATS by default) |
void |
setScanMode(ScanMode scanMode)
Scan mode,
ScanMode.SINGLE by default |
void |
setTouchFocusEnabled(boolean touchFocusEnabled)
Enable or disable touch focus.
|
void |
setZoom(int zoom)
Set current zoom value (between
0 and Camera.Parameters.getMaxZoom(), if larger,
max zoom value will be set |
void |
startPreview()
Start camera preview
Requires Manifest.permission#CAMERA permission |
void |
stopPreview()
Stop camera preview
|
public static final java.util.List<BarcodeFormat> ALL_FORMATS
public static final java.util.List<BarcodeFormat> ONE_DIMENSIONAL_FORMATS
public static final java.util.List<BarcodeFormat> TWO_DIMENSIONAL_FORMATS
public static final int CAMERA_BACK
public static final int CAMERA_FRONT
public CodeScanner(android.content.Context context,
CodeScannerView view)
context - Contextview - A view to display the previewCodeScannerViewpublic CodeScanner(android.content.Context context,
CodeScannerView view,
int cameraId)
context - Contextview - A view to display the previewcameraId - Camera id (between 0 and
Camera.getNumberOfCameras() - 1)
or CAMERA_BACK or CAMERA_FRONTCodeScannerViewpublic int getCamera()
CAMERA_BACK or CAMERA_FRONTsetCamera(int)public void setCamera(int cameraId)
cameraId - Camera id (between 0 and
Camera.getNumberOfCameras() - 1)
or CAMERA_BACK or CAMERA_FRONTpublic java.util.List<BarcodeFormat> getFormats()
setFormats(List)public void setFormats(java.util.List<BarcodeFormat> formats)
ALL_FORMATS by default)formats - FormatsBarcodeFormat,
ALL_FORMATS,
ONE_DIMENSIONAL_FORMATS,
TWO_DIMENSIONAL_FORMATSpublic DecodeCallback getDecodeCallback()
public void setDecodeCallback(DecodeCallback decodeCallback)
decodeCallback - CallbackDecodeCallbackpublic ErrorCallback getErrorCallback()
public void setErrorCallback(ErrorCallback errorCallback)
errorCallback - CallbackErrorCallback.SUPPRESS,
ErrorCallbackpublic ScanMode getScanMode()
public void setScanMode(ScanMode scanMode)
ScanMode.SINGLE by defaultScanModepublic int getZoom()
public void setZoom(int zoom)
0 and Camera.Parameters.getMaxZoom(), if larger,
max zoom value will be setpublic boolean isTouchFocusEnabled()
public void setTouchFocusEnabled(boolean touchFocusEnabled)
public boolean isAutoFocusEnabled()
setAutoFocusEnabled(boolean)public void setAutoFocusEnabled(boolean autoFocusEnabled)
true by defaultpublic AutoFocusMode getAutoFocusMode()
public void setAutoFocusMode(AutoFocusMode autoFocusMode)
AutoFocusMode.SAFE by defaultAutoFocusModepublic void setAutoFocusInterval(long autoFocusInterval)
AutoFocusMode.SAFE mode, 2000 by defaultpublic boolean isFlashEnabled()
public void setFlashEnabled(boolean flashEnabled)
false by defaultpublic boolean isPreviewActive()
public void startPreview()
Manifest.permission#CAMERA permissionpublic void stopPreview()
public void releaseResources()
Activity.onPause()