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.
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.
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