RemoteModelManager

public class RemoteModelManager extends Object

Manages remote models.

Before using a remote model, download it with RemoteModelManager.

This class is thread safe.

Task<Void>
deleteDownloadedModel(RemoteModel remoteModel)
Deletes the given remoteModel from disk.
Task<Void>
download(RemoteModel remoteModel, DownloadConditions downloadConditions)
Initiates the download of remoteModel if the download hasn't begun.
<T extends RemoteModel> Task<Set<T>>
getDownloadedModels(Class<T> modelType)
Returns the set of all currently downloaded models of the given modelType.
synchronized static RemoteModelManager
getInstance()
Gets the RemoteModelManager instance.
Task<Boolean>
isModelDownloaded(RemoteModel remoteModel)
Returns whether the given remoteModel is currently downloaded.

Inherited Method Summary

Object
clone()
boolean
equals(Object arg0)
void
finalize()
final Class<?>
getClass()
int
hashCode()
final void
notify()
final void
notifyAll()
String
toString()
final void
wait(long arg0, int arg1)
final void
wait(long arg0)
final void
wait()

Public Methods

public Task<Void> deleteDownloadedModel (RemoteModel remoteModel)

Deletes the given remoteModel from disk. Does nothing if the model is not downloaded.

public Task<Void> download (RemoteModel remoteModel, DownloadConditions downloadConditions)

Initiates the download of remoteModel if the download hasn't begun.

If the model's download is already in progress, the current download task will be returned.

If the model is already downloaded to the device, and there is no update, the task will immediately succeed.

If the model is already downloaded to the device, and there is update, a download for the updated version will be attempted.

If the model downloaded failed, the returned Task will contain a MlKitException. Downloads for each type of model may encounter different MlKitException.ErrorCodes. Please check detailed documentation of each RemoteModel class for possible MlKitException.ErrorCodes.

Returns
  • the task for the remoteModel download

public Task<Set<T>> getDownloadedModels (Class<T> modelType)

Returns the set of all currently downloaded models of the given modelType.

public static synchronized RemoteModelManager getInstance ()

Gets the RemoteModelManager instance.

public Task<Boolean> isModelDownloaded (RemoteModel remoteModel)

Returns whether the given remoteModel is currently downloaded.