BarcodeScannerOptions.Builder
Stay organized with collections
Save and categorize content based on your preferences.
Public Constructor Summary
Inherited Method Summary
From class java.lang.Object
Object
|
clone()
|
boolean |
|
void |
finalize()
|
final Class<?>
|
getClass()
|
int |
hashCode()
|
final void |
notify()
|
final void |
notifyAll()
|
String
|
toString()
|
final void |
wait(long arg0, int arg1)
|
final void |
wait(long arg0)
|
final void |
wait()
|
Public Methods
Returns all potential barcodes when enabled, even if they cannot be decoded.
Barcode.getRawBytes()
and Barcode.getRawValue()
will return null
for any undecoded barcodes, but
Barcode.getBoundingBox()
will return the area potentially containing a
barcode.
This can be used to facilitate further detection, e.g., by zooming in the camera to
get a clearer image of any barcode in the returned bounding box.
Sets the interested barcode formats defined in Barcode.BarcodeFormat
.
e.g. setBarcodeFormats(Barcode.FORMAT_QR_CODE,
Barcode.FORMAT_UPC_A)
.
Reducing the number of supported formats will make the barcode scanner faster.
Only the last call will be respected if calling this method multiple times
Default: all formats are supported.
Parameters
format |
supported barcode format |
moreFormats |
more supported barcode formats |
Sets the custom Executor
to use. If no Executor
is set, an internal background thread pool will be used.
Most clients should not need to call this method.
Returns
- this object, for chaining method calls
Sets the ZoomSuggestionOptions
to use.
If this is specified, then the library will suggest zooming the camera if the
barcode is too far away or too small to be detected.
Returns
- this object, for chaining method calls.
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2024-10-31 UTC.
[null,null,["Last updated 2024-10-31 UTC."],[[["\u003cp\u003e\u003ccode\u003eBarcodeScannerOptions.Builder\u003c/code\u003e helps create customized barcode scanning configurations using methods like \u003ccode\u003esetBarcodeFormats\u003c/code\u003e and \u003ccode\u003eenableAllPotentialBarcodes\u003c/code\u003e.\u003c/p\u003e\n"],["\u003cp\u003eIt allows specifying the desired barcode formats for faster scanning and the option to receive all potential barcodes, even if undecoded.\u003c/p\u003e\n"],["\u003cp\u003eDevelopers can further customize the scanning process by setting a custom Executor for task execution and defining zoom suggestions using \u003ccode\u003esetZoomSuggestionOptions\u003c/code\u003e.\u003c/p\u003e\n"],["\u003cp\u003eThe \u003ccode\u003ebuild()\u003c/code\u003e method is used to finalize and generate a \u003ccode\u003eBarcodeScannerOptions\u003c/code\u003e instance based on the provided configurations.\u003c/p\u003e\n"]]],["The `BarcodeScannerOptions.Builder` class builds `BarcodeScannerOptions` instances. Key actions include: building an instance via `build()`; enabling the return of all potential barcodes with `enableAllPotentialBarcodes()`, even if undecoded; specifying supported barcode formats using `setBarcodeFormats()`; setting a custom `Executor` using `setExecutor()`; and defining zoom behavior using `setZoomSuggestionOptions()`. Each method returns the builder object to allow method chaining. The builder has a constructor `Builder()`.\n"],null,["# BarcodeScannerOptions.Builder\n\npublic static class **BarcodeScannerOptions.Builder** extends [Object](//developer.android.com/reference/java/lang/Object.html) \nBuilder to build out a [BarcodeScannerOptions](/android/reference/com/google/mlkit/vision/barcode/BarcodeScannerOptions). \n\n### Public Constructor Summary\n\n|---|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| | [Builder](/android/reference/com/google/mlkit/vision/barcode/BarcodeScannerOptions.Builder#Builder())() Builder for [BarcodeScannerOptions](/android/reference/com/google/mlkit/vision/barcode/BarcodeScannerOptions). |\n\n### Public Method Summary\n\n|-------------------------------------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| [BarcodeScannerOptions](/android/reference/com/google/mlkit/vision/barcode/BarcodeScannerOptions) | [build](/android/reference/com/google/mlkit/vision/barcode/BarcodeScannerOptions.Builder#build())() Builds a [BarcodeScannerOptions](/android/reference/com/google/mlkit/vision/barcode/BarcodeScannerOptions) instance. |\n| [BarcodeScannerOptions.Builder](/android/reference/com/google/mlkit/vision/barcode/BarcodeScannerOptions.Builder) | [enableAllPotentialBarcodes](/android/reference/com/google/mlkit/vision/barcode/BarcodeScannerOptions.Builder#enableAllPotentialBarcodes())() Returns all potential barcodes when enabled, even if they cannot be decoded. |\n| [BarcodeScannerOptions.Builder](/android/reference/com/google/mlkit/vision/barcode/BarcodeScannerOptions.Builder) | [setBarcodeFormats](/android/reference/com/google/mlkit/vision/barcode/BarcodeScannerOptions.Builder#setBarcodeFormats(int,%20int...))(int format, int... moreFormats) Sets the interested barcode formats defined in [Barcode.BarcodeFormat](/android/reference/com/google/mlkit/vision/barcode/common/Barcode.BarcodeFormat). |\n| [BarcodeScannerOptions.Builder](/android/reference/com/google/mlkit/vision/barcode/BarcodeScannerOptions.Builder) | [setExecutor](/android/reference/com/google/mlkit/vision/barcode/BarcodeScannerOptions.Builder#setExecutor(java.util.concurrent.Executor))([Executor](//developer.android.com/reference/java/util/concurrent/Executor.html) executor) Sets the custom [Executor](//developer.android.com/reference/java/util/concurrent/Executor.html) to use. |\n| [BarcodeScannerOptions.Builder](/android/reference/com/google/mlkit/vision/barcode/BarcodeScannerOptions.Builder) | [setZoomSuggestionOptions](/android/reference/com/google/mlkit/vision/barcode/BarcodeScannerOptions.Builder#setZoomSuggestionOptions(com.google.mlkit.vision.barcode.ZoomSuggestionOptions))([ZoomSuggestionOptions](/android/reference/com/google/mlkit/vision/barcode/ZoomSuggestionOptions) zoomSuggestionOptions) Sets the [ZoomSuggestionOptions](/android/reference/com/google/mlkit/vision/barcode/ZoomSuggestionOptions) to use. |\n\n### Inherited Method Summary\n\nFrom class java.lang.Object \n\n|----------------------------------------------------------------------------|--------------------------------------------------------------------------------|\n| [Object](//developer.android.com/reference/java/lang/Object.html) | clone() |\n| boolean | equals([Object](//developer.android.com/reference/java/lang/Object.html) arg0) |\n| void | finalize() |\n| final [Class](//developer.android.com/reference/java/lang/Class.html)\\\u003c?\\\u003e | getClass() |\n| int | hashCode() |\n| final void | notify() |\n| final void | notifyAll() |\n| [String](//developer.android.com/reference/java/lang/String.html) | toString() |\n| final void | wait(long arg0, int arg1) |\n| final void | wait(long arg0) |\n| final void | wait() |\n\nPublic Constructors\n-------------------\n\n#### public **Builder** ()\n\nBuilder for [BarcodeScannerOptions](/android/reference/com/google/mlkit/vision/barcode/BarcodeScannerOptions).\n\nPublic Methods\n--------------\n\n#### public [BarcodeScannerOptions](/android/reference/com/google/mlkit/vision/barcode/BarcodeScannerOptions)\n**build** ()\n\nBuilds a [BarcodeScannerOptions](/android/reference/com/google/mlkit/vision/barcode/BarcodeScannerOptions)\ninstance. \n\n#### public [BarcodeScannerOptions.Builder](/android/reference/com/google/mlkit/vision/barcode/BarcodeScannerOptions.Builder)\n**enableAllPotentialBarcodes** ()\n\nReturns all potential barcodes when enabled, even if they cannot be decoded.\n\n[Barcode.getRawBytes()](/android/reference/com/google/mlkit/vision/barcode/common/Barcode#getRawBytes())\nand [Barcode.getRawValue()](/android/reference/com/google/mlkit/vision/barcode/common/Barcode#getRawValue())\nwill return `null` for any undecoded barcodes, but [Barcode.getBoundingBox()](/android/reference/com/google/mlkit/vision/barcode/common/Barcode#getBoundingBox()) will return the area potentially containing a\nbarcode.\n\nThis can be used to facilitate further detection, e.g., by zooming in the camera to\nget a clearer image of any barcode in the returned bounding box. \n\n#### public [BarcodeScannerOptions.Builder](/android/reference/com/google/mlkit/vision/barcode/BarcodeScannerOptions.Builder)\n**setBarcodeFormats** (int format, int... moreFormats)\n\nSets the interested barcode formats defined in [Barcode.BarcodeFormat](/android/reference/com/google/mlkit/vision/barcode/common/Barcode.BarcodeFormat).\n\ne.g. `setBarcodeFormats(Barcode.FORMAT_QR_CODE,\nBarcode.FORMAT_UPC_A)`.\n\nReducing the number of supported formats will make the barcode scanner faster.\n\nOnly the last call will be respected if calling this method multiple times\n\nDefault: all formats are supported. \n\n##### Parameters\n\n| format | supported barcode format |\n| moreFormats | more supported barcode formats |\n|-------------|--------------------------------|\n\n#### public [BarcodeScannerOptions.Builder](/android/reference/com/google/mlkit/vision/barcode/BarcodeScannerOptions.Builder)\n**setExecutor** ([Executor](//developer.android.com/reference/java/util/concurrent/Executor.html) executor)\n\nSets the custom [Executor](//developer.android.com/reference/java/util/concurrent/Executor.html)\nto use. If no [Executor](//developer.android.com/reference/java/util/concurrent/Executor.html)\nis set, an internal background thread pool will be used.\n\nMost clients should not need to call this method. \n\n##### Parameters\n\n| executor | the [Executor](//developer.android.com/reference/java/util/concurrent/Executor.html) to use |\n|----------|---------------------------------------------------------------------------------------------|\n\n##### Returns\n\n- this object, for chaining method calls \n\n#### public [BarcodeScannerOptions.Builder](/android/reference/com/google/mlkit/vision/barcode/BarcodeScannerOptions.Builder)\n**setZoomSuggestionOptions** ([ZoomSuggestionOptions](/android/reference/com/google/mlkit/vision/barcode/ZoomSuggestionOptions) zoomSuggestionOptions)\n\nSets the [ZoomSuggestionOptions](/android/reference/com/google/mlkit/vision/barcode/ZoomSuggestionOptions)\nto use.\n\nIf this is specified, then the library will suggest zooming the camera if the\nbarcode is too far away or too small to be detected. \n\n##### Parameters\n\n| zoomSuggestionOptions | the [ZoomSuggestionOptions](/android/reference/com/google/mlkit/vision/barcode/ZoomSuggestionOptions) to use |\n|-----------------------|--------------------------------------------------------------------------------------------------------------|\n\n##### Returns\n\n- this object, for chaining method calls."]]