BarcodeScanner
Contents
[
Hide
]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
Constructor | Description |
---|---|
BarcodeScanner(ComponentActivity parentActivity) | Initializes a new instance of the BarcodeScanner class. |
Methods
Method | Description |
---|---|
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:
Parameter | Type | Description |
---|---|---|
parentActivity | androidx.activity.ComponentActivity | activity from witch called BarcodeScanner. Should be initialized before the parent activity view will be created |
equals(Object arg0)
public boolean equals(Object arg0)
Parameters:
Parameter | Type | Description |
---|---|---|
arg0 | java.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:
Parameter | Type | Description |
---|---|---|
barcodeRecognitionResultsHandler | com.aspose.barcode.component.barcodescanner.BarcodeRecognitionResultsHandlerParcelable | Custom 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:
Parameter | Type | Description |
---|---|---|
onBarcodeScannerCompletedCallback | com.aspose.barcode.component.barcodescanner.OnBarcodeScannerCompletedCallback | listener |
toString()
public String toString()
Returns: java.lang.String
wait()
public final void wait()
wait(long arg0)
public final native void wait(long arg0)
Parameters:
Parameter | Type | Description |
---|---|---|
arg0 | long |
wait(long arg0, int arg1)
public final void wait(long arg0, int arg1)
Parameters:
Parameter | Type | Description |
---|---|---|
arg0 | long | |
arg1 | int |