Results
Obtaining the Measurement Results
After the upload of your scanned frames is completed (that is, the TireTreadScanView
's callback method onUploadCompleted
was invoked), your measurement results may still take a few seconds to become available. To fetch the results, call the function getTreadDepthReportResult(measurementUuid)
:
class MeasurementResultActivity(
private val backgroundDispatcher: CoroutineDispatcher = Dispatchers.IO
) : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_measurement_result)
var measurementUuid: String = ""
val bundle = intent.extras
bundle?.also {
measurementUuid = it.getString("measurement_uuid") ?: ""
}
// Display some "loading" information
// Run the fetchResults in a background thread
lifecycleScope.launch(backgroundDispatcher) {
fetchResults(measurementUuid)
}
}
private fun fetchResults(measurementUuid: String) {
Log.d("MY_APP", "Checking for results for UUID - $measurementUuid - ...")
AnylineTireTreadSdk.getTreadDepthReportResult(
measurementUuid,
onGetTreadDepthReportResultSucceeded = { result: TreadDepthResult ->
Log.d("MY_APP", "$measurementUuid result is available")
runOnUiThread {
displayMeasurementResult(result)
}
},
onGetTreadDepthReportResultFailed = { measurementError: MeasurementError ->
// Handle failure
Log.e("MY_APP", "$measurementUuid failed")
Log.e("MY_APP", "Error Code: ${measurementError.errorCode}")
Log.e("MY_APP", "Error Message: ${measurementError.errorMessage}")
runOnUiThread {
displayError(measurementError.toString())
}
}
)
}
}
Once the result is available, the onGetTreadDepthReportResultSucceeded
callback will be called with the TreadDepthResult
object containing it.
In case of any failure, the onGetTreadDepthReportResultFailed
will be called containing the MeasurementError
object, where you can find the error code and message.
A timeoutSeconds
parameter can also be passed to the function, limitting for how long the result fetching can run before being interrupted (in case of bad network connection, etc.).
TreadDepthResult
The TreadDepthResult
represents the result of a tread depth measurement. It contains three properties:
-
global
: An instance of TreadResultRegion representing the global result.-
This value represents the global tread depth of the entire tire.
-
This value is calculated from all individual measurements.
-
-
regions
: A list of TreadResultRegion instances representing the results for each of the identified tire regions.-
This value represents the tread depth of the identified tire regions (for more details, check the PDF Report); It does not represent measurements of single grooves.
-
The regions are always provided considering the direction from Left to Right side of the scanned tire.
-
-
measurementInfo
: An instance of MeasurementInfo providing additional information about the measurement.-
This property holds the Measurement UUID, the measurement’s status (
MeasurementStatus
) and - if provided before the scan process - theadditional context
of your measurement. -
The possible values for the Measurement Status are
WaitingForImages
,Processing
,ResultReady
,ResultAndReportReady
,Completed
,Aborted
,Failed
, andUnknown
. -
The results are only available when the measurement’s status is
ResultReady
,ResultAndReportReady
, orCompleted
.
-
PDF Report
To retrieve the PDF report of a measurement, use the function getTreadDepthReportPdf(uuid)
from the AnylineTireTreadSdk
class. The PDF will be returned as a byte array.
The return value can then be saved and displayed as best fitting your application’s workflow, e.g.:
try {
AnylineTireTreadSdk.getTreadDepthReportPdf(uuid, { pdfData ->
// Create a temporary file
val tmpPdfFile = File.createTempFile("ttr_report-", ".pdf")
// Write the PDF data into it
val fos = FileOutputStream(tmpPdfFile)
fos.write(pdfData)
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)
}, { exception ->
Log.e("Showcase", "Exception raised while loading the PDF", exception)
Toast.makeText(
this, "The detailed report cannot be displayed at the moment.", Toast.LENGTH_SHORT
).show()
})
} catch (e: Exception) {
Log.e("MY_APP", "PDF Report issue: ", e)
}
Remember to do/catch the |
The report will only be available when measurement’s status is ResultAndReportReady
, or Completed
.
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.2)
val regionInch = TreadResultRegion.initInch(true, 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) })