Scan Process - Android

The AnylineTireTreadSDK allows for a variety of options on how to set up the scan process. In the following sections we will show the most convenient and quick way to get started with scanning.

You can check out our Android GitHub repository for a complete example implementation of the TireTreadScanView.

Setup with a config object

  • Compose

  • Xml + ViewBinding

@Composable
private fun Content() {
    // You can pass the tire width as an integer,
    // or let the Default UI request this value from the user
    // by not png this parameter to the TireTreadScanView
    val tireWidth = 200

    TireTreadScanView(context = this@ScanActivity,
        config = TireTreadScanViewConfig()
        /* if needed, you can customize the config, e.g.: */
            // .apply {
            //     defaultUiConfig = DefaultUiConfig()
            //     .apply {
            //      tapToStartScanningTooltipConfig.apply {
            //          textOk = "Start scanning now"
            //      }
            //     ...
            // }
            // measurementSystem = MeasurementSystem.Imperial
        },
        tireWidth = tireWidth,
        onScanAborted = ::onScanAborted,
        onScanProcessCompleted = ::onScanProcessCompleted,
        // Optionally, you can listen to all the scan events to build custom workflows
        // callback = ::handleEvent
    ) { measurementUUID, exception ->
        // handle possible errors during scanning
    }
}

private fun onScanAborted(measurementUUID: String?) {
    // handle scan aborted, e.g. leave the screen
}

private fun onScanProcessCompleted(measurementUUID: String) {
    // handle scan process completed, e.g. show a results page
}

// private fun handleEvent(event: ScanEvent) {
//     when(event) {
//         is OnScanStart -> {
//             // handle onScanStart event
//         }
//         // handle other events
//         else -> {
//             // handle previously unhandled events
//         }
//     }
// }
override fun onCreate(savedInstanceState: Bundle?) {
    binding.tireTreadScanView.apply {
        // You can pass the tire width as an integer,
        // or let the Default UI request this value from the user
        // by not passing this parameter to the TireTreadScanView
        val tireWidth = 200

        init(tireTreadScanViewConfig = TireTreadScanViewConfig()
            /* if needed, you can customize the config, e.g.: */
            // .apply {
            //     defaultUiConfig = DefaultUiConfig().apply {
            //         tireOverlayConfig = TireOverlayConfig().apply {
            //             visible = true
            //         }
            //     // ...
            // }
            // measurementSystem = MeasurementSystem.Imperial
        },
            tireWidth = tireWidth,
            onScanAborted = ::onScanAborted,
            onScanProcessCompleted = ::onScanProcessCompleted,
            // Optionally, you can listen to all the scan events to build custom workflows
            // tireTreadScanViewCallback = ::handleEvent
        ) { measurementUUID, exception ->
            // handle possible errors during scanning
        }
        setViewCompositionStrategy(
            ViewCompositionStrategy.DisposeOnLifecycleDestroyed(
                this@ScanActivity
            )
        )
    }
}

private fun onScanAborted(measurementUUID: String?) {
    // handle scan aborted
}

private fun onScanProcessCompleted(measurementUUID: String) {
    // handle scan process completed
}

// private fun handleEvent(event: ScanEvent) {
//     when(event) {
//         is OnScanStart -> {
//             // handle onScanStart event
//         }
//         // handle other events
//         else -> {
//             // handle previously unhandled events
//         }
//     }
// }

Setup with JSON config

Another way to configure the TireTreadScanView is via a JSON config. You can provide the name of a .json file located in your application’s asset folder, or even the full JSON string as an input.

@Composable
private fun Content() {
    // You can pass the tire width as an integer,
    // or let the Default UI request this value from the user
    // by not passing this parameter to the TireTreadScanView
    val tireWidth = 200

    TireTreadScanView(context = this@ScanActivity,
        tireTreadScanViewConfig = "my_scan_config.json", //you can also use the full JSON string as an input!
        tireWidth = tireWidth,
        onScanAborted = ::onScanAborted,
        onScanProcessCompleted = ::onScanProcessCompleted,
        // Optionally, you can listen to all the scan events to build custom workflows
        // callback = ::handleEvent
        ) { measurementUUID, exception ->
            // handle possible errors
        }
}

// private fun handleEvent(event: ScanEvent) {
//     when(event) {
//         is OnScanStart -> {
//             // handle onScanStart event
//         }
//         // handle other events
//         else -> {
//             // handle previously unhandled events
//         }
//     }
// }

private fun onScanAborted(measurementUUID: String?) {
    // handle scan aborted
}

private fun onScanProcessCompleted(measurementUUID: String) {
    // handle scan process completed
}
You can check out our GitHub example repository for an implementation of the Scan Activity.

Check out the next section to learn how to handle the measurement results after the scan process is finished.