RemoteModelManager
Stay organized with collections
Save and categorize content based on your preferences.
Manages remote models.
Before using a remote model, download it with RemoteModelManager
.
This class is thread safe.
Inherited Method Summary
From class java.lang.Object
Object
|
clone()
|
boolean |
|
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.
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.ErrorCode
s.
Please check detailed documentation of each RemoteModel class for possible
MlKitException.ErrorCode
s.
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 Task<Boolean>
isModelDownloaded (RemoteModel
remoteModel)
Returns whether the given remoteModel
is currently downloaded.
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2024-10-31 UTC.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2024-10-31 UTC."],[[["\u003cp\u003e\u003ccode\u003eRemoteModelManager\u003c/code\u003e is a class used to manage remote models in your Android app, ensuring thread-safe operations.\u003c/p\u003e\n"],["\u003cp\u003eYou can use it to download, delete, and check the download status of remote models, including getting a list of all downloaded models of a specific type.\u003c/p\u003e\n"],["\u003cp\u003eInitiating a download with \u003ccode\u003eRemoteModelManager\u003c/code\u003e handles various scenarios such as ongoing downloads, updates, and errors with specific error codes.\u003c/p\u003e\n"],["\u003cp\u003eYou can get an instance of \u003ccode\u003eRemoteModelManager\u003c/code\u003e using the \u003ccode\u003egetInstance()\u003c/code\u003e method to start using its functionalities.\u003c/p\u003e\n"],["\u003cp\u003eThe class provides methods like \u003ccode\u003edeleteDownloadedModel\u003c/code\u003e, \u003ccode\u003edownload\u003c/code\u003e, \u003ccode\u003egetDownloadedModels\u003c/code\u003e, \u003ccode\u003egetInstance\u003c/code\u003e, and \u003ccode\u003eisModelDownloaded\u003c/code\u003e for model management.\u003c/p\u003e\n"]]],[],null,["# RemoteModelManager\n\npublic class **RemoteModelManager** extends [Object](//developer.android.com/reference/java/lang/Object.html) \nManages remote models.\n\nBefore using a remote model, download it with [RemoteModelManager](/android/reference/com/google/mlkit/common/model/RemoteModelManager).\n\nThis class is thread safe. \n\n### Public Method Summary\n\n|--------------------------------------------------------------------------------------------------------------------------------------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| Task\\\u003c[Void](//developer.android.com/reference/java/lang/Void.html)\\\u003e | [deleteDownloadedModel](/android/reference/com/google/mlkit/common/model/RemoteModelManager#deleteDownloadedModel(com.google.mlkit.common.model.RemoteModel))([RemoteModel](/android/reference/com/google/mlkit/common/model/RemoteModel) remoteModel) Deletes the given `remoteModel` from disk. |\n| Task\\\u003c[Void](//developer.android.com/reference/java/lang/Void.html)\\\u003e | [download](/android/reference/com/google/mlkit/common/model/RemoteModelManager#download(com.google.mlkit.common.model.RemoteModel,%20com.google.mlkit.common.model.DownloadConditions))([RemoteModel](/android/reference/com/google/mlkit/common/model/RemoteModel) remoteModel, [DownloadConditions](/android/reference/com/google/mlkit/common/model/DownloadConditions) downloadConditions) Initiates the download of `remoteModel` if the download hasn't begun. |\n| \\\u003cT extends [RemoteModel](/android/reference/com/google/mlkit/common/model/RemoteModel)\\\u003e Task\\\u003c[Set](//developer.android.com/reference/java/util/Set.html)\\\u003cT\\\u003e\\\u003e | [getDownloadedModels](/android/reference/com/google/mlkit/common/model/RemoteModelManager#getDownloadedModels(java.lang.Class\u003cT\u003e))([Class](//developer.android.com/reference/java/lang/Class.html)\\\u003cT\\\u003e modelType) Returns the set of all currently downloaded models of the given `modelType`. |\n| synchronized static [RemoteModelManager](/android/reference/com/google/mlkit/common/model/RemoteModelManager) | [getInstance](/android/reference/com/google/mlkit/common/model/RemoteModelManager#getInstance())() Gets the [RemoteModelManager](/android/reference/com/google/mlkit/common/model/RemoteModelManager) instance. |\n| Task\\\u003c[Boolean](//developer.android.com/reference/java/lang/Boolean.html)\\\u003e | [isModelDownloaded](/android/reference/com/google/mlkit/common/model/RemoteModelManager#isModelDownloaded(com.google.mlkit.common.model.RemoteModel))([RemoteModel](/android/reference/com/google/mlkit/common/model/RemoteModel) remoteModel) Returns whether the given `remoteModel` is currently downloaded. |\n\n### Inherited Method Summary\n\nFrom class java.lang.Object \n\n|----------------------------------------------------------------------------|--------------------------------------------------------------------------------|\n| [Object](//developer.android.com/reference/java/lang/Object.html) | clone() |\n| boolean | equals([Object](//developer.android.com/reference/java/lang/Object.html) arg0) |\n| void | finalize() |\n| final [Class](//developer.android.com/reference/java/lang/Class.html)\\\u003c?\\\u003e | getClass() |\n| int | hashCode() |\n| final void | notify() |\n| final void | notifyAll() |\n| [String](//developer.android.com/reference/java/lang/String.html) | toString() |\n| final void | wait(long arg0, int arg1) |\n| final void | wait(long arg0) |\n| final void | wait() |\n\nPublic Methods\n--------------\n\n#### public Task\\\u003c[Void](//developer.android.com/reference/java/lang/Void.html)\\\u003e **deleteDownloadedModel** ([RemoteModel](/android/reference/com/google/mlkit/common/model/RemoteModel) remoteModel)\n\nDeletes the given `remoteModel` from disk. Does nothing if the model is\nnot downloaded. \n\n#### public Task\\\u003c[Void](//developer.android.com/reference/java/lang/Void.html)\\\u003e **download** ([RemoteModel](/android/reference/com/google/mlkit/common/model/RemoteModel) remoteModel, [DownloadConditions](/android/reference/com/google/mlkit/common/model/DownloadConditions) downloadConditions)\n\nInitiates the download of `remoteModel` if the download hasn't begun.\n\nIf the model's download is already in progress, the current download task will be\nreturned.\n\nIf the model is already downloaded to the device, and there is no update, the task\nwill immediately succeed.\n\nIf the model is already downloaded to the device, and there is update, a download\nfor the updated version will be attempted.\n\nIf the model downloaded failed, the returned [Task](/android/reference/com/google/android/gms/tasks/Task) will\ncontain a [MlKitException](/android/reference/com/google/mlkit/common/MlKitException).\nDownloads for each type of model may encounter different [MlKitException.ErrorCode](/android/reference/com/google/mlkit/common/MlKitException.ErrorCode)s.\nPlease check detailed documentation of each RemoteModel class for possible\n[MlKitException.ErrorCode](/android/reference/com/google/mlkit/common/MlKitException.ErrorCode)s. \n\n##### Returns\n\n- the task for the `remoteModel` download \n\n#### public Task\\\u003c[Set](//developer.android.com/reference/java/util/Set.html)\\\u003cT\\\u003e\\\u003e\n**getDownloadedModels** ([Class](//developer.android.com/reference/java/lang/Class.html)\\\u003cT\\\u003e modelType)\n\nReturns the set of all currently downloaded models of the given\n`modelType`. \n\n#### public static synchronized [RemoteModelManager](/android/reference/com/google/mlkit/common/model/RemoteModelManager)\n**getInstance** ()\n\nGets the [RemoteModelManager](/android/reference/com/google/mlkit/common/model/RemoteModelManager)\ninstance. \n\n#### public Task\\\u003c[Boolean](//developer.android.com/reference/java/lang/Boolean.html)\\\u003e\n**isModelDownloaded** ([RemoteModel](/android/reference/com/google/mlkit/common/model/RemoteModel) remoteModel)\n\nReturns whether the given `remoteModel` is currently downloaded."]]