-1

Image

I want to check which languages are downloaded yet so that I can show or hide this image icon. (Mlkit translate)

I want the source code of how to do this.

IT Student
  • 13
  • 3

1 Answers1

0

You can use below codes to check whether the model is downloaded or not:

DownloadConditions conditions = new DownloadConditions.Builder()
    .requireWifi()
    .build();
englishGermanTranslator.downloadModelIfNeeded(conditions)
    .addOnSuccessListener(
        new OnSuccessListener() {
          @Override
          public void onSuccess(Void v) {
            // Model downloaded successfully. Okay to start translating.
            // (Set a flag, unhide the translation UI, etc.)
          }
        })
    .addOnFailureListener(
        new OnFailureListener() {
          @Override
          public void onFailure(@NonNull Exception e) {
            // Model couldn’t be downloaded or other internal error.
            // ...
          }
        });

More information here: https://developers.google.com/ml-kit/language/translation/android