QRCodeScannerSDKConstants for Android

The QRCodeScannerSDKConstants class contains the constants. The following table lists the available constants and parameters.

Properties

QRCodeScannerSDKConstants Properties for Android
Property Name Data Type Description
Android Extra Parameters
EXTRA_VIBRATE Boolean

Indicates whether the device must vibrate when a QR code is scanned.

Key value: extra_vibrate

Default value: true

EXTRA_CODE_TYPE int

Indicates which type of code can be parsed.

Key value: extra_code_type

Possible values are:

  • QRCodeScannerSDKConstants.QR_CODE
  • QRCodeScannerSDKConstants.CRONTO_CODE
  • QRCodeScannerSDKConstants.QR_CODE + QRCodeScannerSDKConstants.CRONTO_CODE

Default value: QRCodeScannerSDKConstants.QR_CODE + QRCodeScannerSDKConstants.CRONTO_CODE

QR_CODE int

Indicates that the Image Scanner SDK must parse the image to search QR codes.

Key value: 0x01

EXTRA_SCANNER_OVERLAY Boolean

Indicates that a scanner overlay will be displayed in scan view.

Key value: extra_scanner_overlay

Default value: false

EXTRA_SCANNER_OVERLAY_COLOR int

Indicates the color that will be applied in the scanner overlay.

Key value: extra_scanner_overlay_color

Default value: 0x99000000

CRONTO_CODE int

Indicates that the Image Scanner SDK must parse the image to search Cronto images.

Key value: 0x02

Android Return Parameters
OUTPUT_RESULT String

Result of the scan.

Key value: output_result

OUTPUT_EXCEPTION Exception

Caught exception.

Key value: output_exception

OUTPUT_CODE_TYPE int

Code type result.

Key value: output_code_type

Possible values are:

  • QR_CODE
  • CRONTO_CODE
RESULT_ERROR int

Indicates whether an exception has been thrown during the scanning process.

Key value: RESULT_FIRST_USER + 1

Example

  1. public void OnScanClicked(View v)
  2. {
  3.   ..
  4.   // We want a vibration feedback after scanning
  5.   // Note that the vibration feedback is activated by default
  6.   intent.putExtra(QRCodeScannerSDKConstants.EXTRA_VIBRATE, true);
  7.  
  8.   // Indicate which sort of image we want to scan
  9.   intent.putExtra(QRCodeScannerSDKConstants.EXTRA_CODE_TYPE, QRCodeScannerSDKConstants.QR_CODE +  QRCodeScannerSDKConstants.CRONTO_CODE);
  10.  
  11.   // Launch Image Scanner activity
  12.   startActivityForResult(intent, 1);
  13. }
  14. @Override
  15. protected void onActivityResult(int requestCode, int resultCode, Intent data)
  16. {
  17.   switch (resultCode)
  18.   {
  19.     case RESULT_OK:
  20.       ..
  21.       String result = data.getStringExtra (QRCodeScannerSDKConstants.OUTPUT_RESULT);
  22.       int codeType = data.getIntExtra (QRCodeScannerSDKConstants.OUTPUT_CODE_TYPE, 0);
  23.  
  24.       // Convert the result
  25.       if (codeType == QRCodeScannerSDKConstants.CRONTO_CODE)
  26.       {
  27.         // we have scan a cronto code => convert the hexa string to string
  28.         byte[] tmp = hexaToBytes(result);
  29.         ..
  30.       }
  31.       else if (codeType == QRCodeScannerSDKConstants.QR_CODE)
  32.       {
  33.         // we have scanned a QR code => display directly the result
  34.         resultTextView.setText(result);
  35.         ..
  36.       }
  37.   }
  38. }

Known Issue

Known issue with Samsung Galaxy A23

Due to a known issue with the camera on Samsung Galaxy A23, Cronto codes are not decoded properly with the default resolution. The solution to this issue is to increase the resolution using the following code snippet:

var imageAnalysisBuilder = ImageAnalysis.Builder().setTargetRotation(rotation)
// Set Resolution property only for Samsung Galaxy A23 model
if(Build.MANUFACTURER.equals("Samsung", true) && Build.MODEL.contains("A23")) {
          imageAnalysisBuilder.setTargetResolution(Size(1080, 1920))
}
imageAnalysisBuilder.build().setAnalyzer(cameraExecutor, QrCodeAnalyzer())