Results

Obtaining the Measurement Results

After the upload of your scanned frames is completed (i.e. the TireTreadScanView's callback method onUploadCompleted is invoked), your measurement results may still take a few seconds to become available. To fetch the results, your application should implement a polling logic.

We recommend fetching results once every 3 seconds, until the result - or failure - is available. The results can be fetched and obtained using the function getTreadDepthReportResult(measurementUuid), e.g.:

class MeasurementResultActivity : AppCompatActivity() {

    private val resultTimer = Timer()

    private val resultUpdateTask = object : TimerTask() {
        override fun run() {
            var measurementFailed = false

            Log.d("MY_APP", "Checking for results...")

            val measurementResult : TreadDepthResult? = AnylineTireTreadSdk
                    .getTreadDepthReportResult(
                        measurementUuid,
                        onGetTreadDepthReportResultFailed = { _, exception ->
                            // Handle failure
                            Log.e("MY_APP", "Completed with failure: " + exception.message)
                            measurementFailed = true
                        }
                    )

            if (measurementFailed){
                resultTimer.cancel()
                runOnUiThread {
                    // Display an Error
                    // "Make sure you do not move the device too fast and keep the right distance."
                }
            }
            else if (measurementResult != null) {

                resultTimer.cancel()
                Toast.makeText(context, "Result ready!", Toast.LENGTH_LONG).show()
                runOnUiThread {
                    // Display your results
                }
            }
        }
    }

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_measurement_result)

        // Display some "loading" information

        // Schedule your polling logic
        resultTimer.schedule(resultUpdateTask, 0L, 3000L)
    }

    override fun onDestroy() {
        super.onDestroy()
        resultTimer.cancel()
    }

}
Trying to obtain results more than once every 2 seconds will not result in any performance increase nor in faster results.

PDF Report

As with the results, to retrieve the PDF report of a measurement, you can poll the function getTreadDepthReportPdf(uuid) from the AnylineTireTreadSdk class every 3 seconds, until the PDF is available and returned as a byte array. The return value can then be saved and displayed as best fitting your application’s workflow, e.g.:

try {
    val data = AnylineTireTreadSdk.getTreadDepthReportPdf(uuid)
    // Create a temporary file
    val tmpPdfFile = File.createTempFile("ttr_report-", ".pdf")

    // Write the PDF data into it
    val fos = FileOutputStream(tmpPdfFile)
    fos.write(data)
    fos.close()

    // Prepare to show
    val browserIntent = Intent(Intent.ACTION_VIEW)
    val uri = FileProvider.getUriForFile(
        applicationContext,
        "$packageName.provider",
        tmpPdfFile
    )
    browserIntent.setDataAndType(uri, "application/pdf")
    browserIntent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION)

    val chooser = Intent.createChooser(browserIntent, "Open with")
    chooser.flags = Intent.FLAG_ACTIVITY_NEW_TASK

    startActivity(chooser)
} catch (e: Exception) {
    Log.e("MY_APP", "PDF Report issue: ", e)
}

Remember to try/catch the getTreadDepthReportPdf() function, as the PDF report may not yet be available.

The PDF report will only be available if the TreadDepthResult was previously available, so the best workflow is to first check for results, and only then try to obtain the PDF report.

User Corrected Values and Comments

User Comments

To send a comment on a measurement, use the sendCommentFeedback function of the AnylineTireTreadSdk.

As usual with the TireTreadSDK, the UUID for the scan must be passed as a parameter. The comment is passed as a string, e.g.:

AnylineTireTreadSdk.sendCommentFeedback(measurementUuid, commentText,
        onSendCommentSucceed =  {
            Toast.makeText(
                this,
                resources.getString("Send comment: Success"),
                Toast.LENGTH_SHORT
            ).show()
        },
        onSendCommentFailed = { _, e ->
            Toast.makeText(
                this,
                resources.getString("Send comment: Failure"),
                Toast.LENGTH_SHORT
            ).show()
        })

User Corrected Region Values

To send user corrected region values, use the sendTreadDepthResultFeedback function from the AnylineTireTreadSdk. The result feedback should be provided as a list of TreadResultRegion, ordered from left to right.

You can only provide feedback for the regions returned by the SDK in the TreadDepthResult object.

The values of all regions need be added to the list before sending the feedback.

The TreadResultRegion objects can be initialized with Millimeters or Inches, e.g.:

val regionMm = TreadResultRegion.initMm(true, 1, 1.2)
val regionInch = TreadResultRegion.initInch(true, 1, 0.047)

val myCorrectedResults: List<TreadResultRegion> = listOf(regionMm, regionInch)

AnylineTireTreadSdk.sendTreadDepthResultFeedback(measurementUuid, myCorrectedResults,
            { Log.i("SHOWCASE", "Send result success.") },
            { _, e -> Log.e("SHOWCASE", "Send result failed.", e) })