2

I'm using google digital ink for handwriting recognition. The models that need to get downloaded once are of 20MB size and the download requires some time. Is there any way to show the progress of the download using a progressbar?

My code is as follows:

fun download(context: Context) {
    var modelIdentifier: DigitalInkRecognitionModelIdentifier? = null
    try {
        modelIdentifier =
            DigitalInkRecognitionModelIdentifier.fromLanguageTag(lang)
    } catch (e: MlKitException) {
        // language tag failed to parse, handle error.
    }

    model = DigitalInkRecognitionModel.builder(modelIdentifier!!).build()

    val remoteModelManager = RemoteModelManager.getInstance()
    remoteModelManager.download(model, DownloadConditions.Builder().build())
        .addOnSuccessListener {
            Log.i("StrokeManager", "Model downloaded")
            Toast.makeText(context, "Model Downloaded", Toast.LENGTH_SHORT).show()

        }
        .addOnFailureListener { e: Exception ->
            Log.e("StrokeManager", "Error while downloading a model: $e")
            Toast.makeText(context, "Model Download Failed", Toast.LENGTH_SHORT).show()
        }
}
Christian Baumann
  • 3,188
  • 3
  • 20
  • 37
kuro
  • 194
  • 9

1 Answers1

8

At this moment, the download API doesn't report the exact downloading progress, e.g. 10%, 20%, 50%... If we see more interests in it, we would consider adding such a support.

By the way, here is the same question asked in ML Kit github repo: https://github.com/googlesamples/mlkit/issues/165

Cody Gray - on strike
  • 239,200
  • 50
  • 490
  • 574
Steven
  • 321
  • 1
  • 7
  • Not supported yet? – Taha Sami Sep 13 '21 at 04:52
  • 1
    We try our best to make MLKit better and better, but unfortunately, given all the other projects we are working on, this specific request hasn't been prioritized yet. Will update here once there is more concrete plan for it. – Steven Sep 14 '21 at 05:45