QR / Barcode Reader Android Tutorial

1. Overview
2. Android Development
2.1 Start / Stop Reader
2.2 Use Read Information
3. References
3.1 API Reference
3.2 Sample


1. Overview

Start developing MAXST ARSDK QR/Barcode Reader on Android Platform. Refer to QR/Barcode Reader Introduction for detailed information.

Refer to Tracker Coordinate System to better understand 3D coordinate system of QR/Barcode Reader.

Prerequisites
QR/Barcode Reader Introduction
Tracker Coordinate System

2. Android Development

Start developing on Android Studio using Java. Please refer to Requirements & Supports to find out which devices are supported.

ARSDK has to properly integrate to an Android Activity. Refer to Life Cycle documents for details.


2.1 Start / Stop Reader

To start or stop the reader, refer to the following code.

※ To change the tracker, destroyTracker() should be called before

CodeScanActivity.Java

@Override
protected void onResume() {
    ...
    TrackerManager.getInstance().startTracker(TrackerManager.TRACKER_TYPE_CODE_SCANNER);
    ...
}

@Override
protected void onPause() {
    ...
    TrackerManager.getInstance().stopTracker();
    ...
}

2.2 Use Read Information

When you point the camera to QR code and Barcode, the code name will be displayed on the screen. Refer to the following code to use the read information.

※ startTracker() should be called before

CodeScanActivity.Java

private static class CodeScanResultHandler extends Handler {
    ...
    @Override
    public void handleMessage(Message msg) {
        ...
        String code = TrackerManager.getInstance().getCodeScanResult();
        if (code != null && code.length() > 0) {
             JSONObject jsonObject = new JSONObject(code);
            activity.codeFormatView.setText(jsonObject.getString("Format"));
            activity.codeValueView.setText(jsonObject.getString("Value"));
        }
        ...
    }
}

3. References

These are additional references to develop QR/Barcode Reader


3.1 API Reference

Following documents explain classes and functions used to run QR/Barcode Reader.

MaxstAR Class

TrackerManager Class

CameraDevice Class


3.2 Sample

For information regarding sample build and run of QR/Barcode Reader, refer to Sample

CodeScanActivity.Java

CodeScanRenderer.Java