Client API. The Codename One framework your app is built on: this runs on the device, not in a backend.
public final class CodeScannerOptions
- Object
- CodeScannerOptions
Configuration for CodeScanner.scan(CodeScannerOptions). Every
setting has a working default, so an application usually changes only the
wording and the accepted symbologies.
CodeScanner.scan(new CodeScannerOptions()
.title("Scan the ticket")
.hint("Hold the QR code inside the frame")
.formats(BarcodeFormat.QR_CODE, BarcodeFormat.AZTEC))
.ready(code -> {
if (code == null) {
return; // the user pressed back
}
admit(code.getValue());
})
.except(error -> Log.e(error));Constructors
public CodeScannerOptions() |
Methods
Inherited methods
Constructor details
CodeScannerOptions
public CodeScannerOptions()Method details
title
public CodeScannerOptions title(String value)Parameters
valueString- the title, or
nullfor no title
Returns
hint
public CodeScannerOptions hint(String value)Parameters
valueString- the instruction, or
nullto show none
Returns
formats
public CodeScannerOptions formats(String... values)Restricts which symbologies are accepted, using the
BarcodeFormat constants. A code in any other format is ignored
and scanning continues, which is what an application that expects a
specific kind of code wants: a stray product barcode in the frame does
not end the scan. The default accepts every format the backend decodes.
This filters results rather than configuring the detector, so it does not make scanning faster.
Parameters
valuesString...- accepted format constants; empty or
nullaccepts every format
Returns
facing
public CodeScannerOptions facing(CameraFacing value)Parameters
valueCameraFacing- the camera to use, or
nullfor the back camera
Returns
torchButton
public CodeScannerOptions torchButton(boolean value)true.Parameters
valueboolean- whether the toggle may be shown
Returns
strict
public CodeScannerOptions strict(boolean value)Accepts a code only when two frames read it identically. By default
this applies to PDF417 codes alone; true extends it to every
symbology and false turns it off for PDF417 too.
Turn this on for codes printed with little or no error correction,
such as a PDF417 at level 0; see
VisionOptions.strictBarcodes(boolean), which this sets on the
scanner’s detector, for why and how frames are compared. It also
reaches a BarcodeScanner built from getVisionOptions(),
and overrides a strictBarcodes set on the options passed to
visionOptions(VisionOptions).
Parameters
valueboolean- whether two matching reads are required
Returns
visionOptions
public CodeScannerOptions visionOptions(VisionOptions value)BarcodeScanner, which is how an iOS build selects
VisionBackends.mlKitBarcodeScanning() instead of Apple Vision.Parameters
valueVisionOptions- analyzer configuration, or
nullfor the defaults
Returns
getTitle
public String getTitle()Returns
nullgetHint
public String getHint()Returns
nullgetFormats
public String[] getFormats()Returns
getFacing
public CameraFacing getFacing()Returns
isTorchButton
public boolean isTorchButton()Returns
isStrict
public boolean isStrict()Returns
getVisionOptions
public VisionOptions getVisionOptions()BarcodeScanner needs to scan the way these options
describe: a copy of the ones passed to
visionOptions(VisionOptions) (or the defaults), plus the
accepted formats(String...) unless those options name formats
of their own, plus strict(boolean) when it was called. So
new BarcodeScanner(options.getVisionOptions()) in a pipeline of your
own detects exactly what CodeScanner.scan(CodeScannerOptions)
would. Each call returns a new object.Returns
null