BarcodeScanner

Inheritance: java.lang.Object

public class BarcodeScanner

BarcodeScanner contains the functionality related to barcode recognition from android device camera.

This sample shows how to use BarcodeScanner.
 
 // BarcodeScanner should be initialized in custom Activity in onCreate method,
 because BarcodeScanner must to initialize BarcodeScannerActivity in application
 BarcodeScanner scanner = new BarcodeScanner(getActivity());
 // Sets OnScanFinishedHandler that takes custom implementation of OnScannerRecognitionFinishedListener.
 // This OnScanFinishedHandler will be called after return from BarcodeScannerActivity
 scanner.setOnScanFinishedHandler(recognitionHandler -> {
                     AlertDialog.Builder dialog = new AlertDialog.Builder(requireContext());
                     dialog.setMessage(((ClientResultsListener)recognitionHandler).resultString);
                     dialog.create().show();
                 });
 // Initialize custom implementation of OnScannerRecognitionFinishedListener
 ClientResultsListener listener = new ClientResultsListener();
 // Launch BarcodeScannerActivity
 scanner.launchBarcodeScanner(listener);

 // Custom implementation of OnScannerRecognitionFinishedListener that process barcode recognition result
 on BarcodeScannerActivity side
 private class CustomResultsListener implements OnScannerRecognitionFinishedListener
 {
     public String resultString;

     public ClientResultsListener() {}

     protected ClientResultsListener(Parcel in) {
         resultString = in.readString();
     }

Constructors

ConstructorDescription
BarcodeScanner(ComponentActivity parentActivity)Initializes a new instance of the BarcodeScanner class.

Methods

MethodDescription
equals(Object arg0)
getClass()
getPreferences()
hashCode()
launchBarcodeScanner(BarcodeRecognitionResultsHandlerParcelable barcodeRecognitionResultsHandler)Launch the camera view and manage the recognition process
notify()
notifyAll()
setOnBarcodeScannerCompletedCallback(OnBarcodeScannerCompletedCallback onBarcodeScannerCompletedCallback)Recognition finished listener
toString()
wait()
wait(long arg0)
wait(long arg0, int arg1)

BarcodeScanner(ComponentActivity parentActivity)

public BarcodeScanner(ComponentActivity parentActivity)

Initializes a new instance of the BarcodeScanner class.

Parameters:

ParameterTypeDescription
parentActivityandroidx.activity.ComponentActivityactivity from witch called BarcodeScanner. Should be initialized before the parent activity view will be created

equals(Object arg0)

public boolean equals(Object arg0)

Parameters:

ParameterTypeDescription
arg0java.lang.Object

Returns: boolean

getClass()

public final native Class<?> getClass()

Returns: java.lang.Class

getPreferences()

public BarcodeScannerPreferences getPreferences()

Returns: com.aspose.barcode.component.barcodescanner.BarcodeScannerPreferences - Barcode scanner preferences

hashCode()

public native int hashCode()

Returns: int

launchBarcodeScanner(BarcodeRecognitionResultsHandlerParcelable barcodeRecognitionResultsHandler)

public void launchBarcodeScanner(BarcodeRecognitionResultsHandlerParcelable barcodeRecognitionResultsHandler)

Launch the camera view and manage the recognition process

Parameters:

ParameterTypeDescription
barcodeRecognitionResultsHandlercom.aspose.barcode.component.barcodescanner.BarcodeRecognitionResultsHandlerParcelableCustom instance of abstract OnScannerRecognitionFinishedListener class that process recognition result

notify()

public final native void notify()

notifyAll()

public final native void notifyAll()

setOnBarcodeScannerCompletedCallback(OnBarcodeScannerCompletedCallback onBarcodeScannerCompletedCallback)

public void setOnBarcodeScannerCompletedCallback(OnBarcodeScannerCompletedCallback onBarcodeScannerCompletedCallback)

Recognition finished listener

Parameters:

ParameterTypeDescription
onBarcodeScannerCompletedCallbackcom.aspose.barcode.component.barcodescanner.OnBarcodeScannerCompletedCallbacklistener

toString()

public String toString()

Returns: java.lang.String

wait()

public final void wait()

wait(long arg0)

public final native void wait(long arg0)

Parameters:

ParameterTypeDescription
arg0long

wait(long arg0, int arg1)

public final void wait(long arg0, int arg1)

Parameters:

ParameterTypeDescription
arg0long
arg1int