Driver licenses issued in USA and Canada have the PDF417 code per the AAMVA Standard. The IDScanner class is used by DriveLicenseScannerDialogFragment and DriveLicenseScannerActivity to find the barcode, if applicable, and extract metadata from the barcode.

By default, the library uses Detector from the Native Vision API to detect 1D and 2D barcodes. If you want to use a different barcode detector, you can wrap it in IDScanner and pass it to the Builder in the arguments bundle. Apps can use either DriverLicenseScannerDialogFragment or DriverLicenseScannerActivity, depending on the app architecture and your preference.

Scanning the driver license

To scan the driver license from your app using the default mode:

Creating a bundle with arguments

Use coding similar to this:

Bundle bundle = new DLSBundle.Builder()
                // --- Optional ---
                .setCaptureFront(captureFront)
                .setCaptureBarcode(captureBarcode)
                .setCaptureBack(captureBack)
                .setCheckHasFace(checkForFace) //Defaults to true
                // ----------------
                .create();

Use the scanner from a FragmentActivity

Use coding similar to this:

void scanDriverLicense() {
    Intent intent = new Intent(this, DriverLicenseScannerActivity.class);
    intent.putExtras(bundle);
    startActivityForResult(intent, DLS_REQUEST_CODE);
}

@Override
protected void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) {
    super.onActivityResult(requestCode, resultCode, data);
    if (requestCode == DLS_REQUEST_CODE && data != null) {
        if (resultCode == RESULT_OK) {
            final DriverLicense driverLicense = DLSBundle.getDriverLicense(data.getExtras());
            // Use DriverLicense here
        } else if (resultCode == RESULT_CANCELED) {
            // Cancelled
        }
    }
}

Use the scanner from a Fragment

Use coding similar to this:

void scanDriverLicense() {
    DriverLicenseScannerDialogFragment.start(this, bundle, new DriverLicenseScannerListener() {
        @Override
        public void onDriverLicenseCaptured(Bundle bundle) {
            final DriverLicense driverLicense = DriverLicenseScannerActivity.DLSBundle.getDriverLicense(bundle);
            // Use DriverLicense here
        }
  
        @Override
        public void onCanceled() {
                    // Cancelled
        }
    });
}