AiPackManager
public
interface
AiPackManager
com.google.android.play.core.aipacks.AiPackManager |
Manages downloads of AI packs.
Summary
Public methods | |
---|---|
abstract
AiPackStates
|
cancel(List<String> packNames)
Requests to cancel the download of the specified AI packs. |
abstract
void
|
clearListeners()
Unregisters all listeners previously added using |
abstract
Task<AiPackStates>
|
fetch(List<String> packNames)
Requests to download the specified AI packs. |
abstract
AiAssetLocation
|
getAiAssetLocation(String packName, String assetPath)
[advanced API] Returns the location of an AI asset in a pack, or |
abstract
AiPackLocation
|
getPackLocation(String packName)
Returns the location of the specified AI pack on the device or |
abstract
Map<String, AiPackLocation>
|
getPackLocations()
Returns the location of all installed AI packs as a mapping from the AI pack name to an |
abstract
Task<AiPackStates>
|
getPackStates(List<String> packNames)
Requests download state or details for the specified AI packs. |
abstract
void
|
registerListener(AiPackStateUpdateListener listener)
Registers a listener that will be notified of changes to the state of pack downloads for this app. |
abstract
Task<Void>
|
removePack(String packName)
Deletes the specified AI pack from the internal storage of the app. |
abstract
boolean
|
showConfirmationDialog(ActivityResultLauncher<IntentSenderRequest> activityResultLauncher)
Shows a dialog that asks the user for consent to download packs that are currently in either
the |
abstract
void
|
unregisterListener(AiPackStateUpdateListener listener)
Unregisters a listener previously added using |
Public methods
cancel
public abstract AiPackStates cancel (List<String> packNames)
Requests to cancel the download of the specified AI packs.
Note: Only active downloads can be canceled.
Parameters | |
---|---|
packNames |
List |
Returns | |
---|---|
AiPackStates |
The new state for all specified packs. |
clearListeners
public abstract void clearListeners ()
Unregisters all listeners previously added using registerListener(AiPackStateUpdateListener)
.
fetch
public abstract Task<AiPackStates> fetch (List<String> packNames)
Requests to download the specified AI packs.
This method will fail if the app is not in the foreground.
Parameters | |
---|---|
packNames |
List |
Returns | |
---|---|
Task<AiPackStates> |
the state of all specified pack names |
getAiAssetLocation
public abstract AiAssetLocation getAiAssetLocation (String packName, String assetPath)
[advanced API] Returns the location of an AI asset in a pack, or null
if the AI asset
is not present in the given pack.
You don't need to use this API for common use-cases: you can use the standard File API for accessing AI assets from packs that were extracted into the filesystem; and you can use Android's AssetManager API to access AI assets from packs that were installed as APKs.
This API is useful for game engines that don't use Asset Manager and for developers that want a unified method to access AI assets, independently from the delivery mode.
Parameters | |
---|---|
packName |
String |
assetPath |
String |
Returns | |
---|---|
AiAssetLocation |
getPackLocation
public abstract AiPackLocation getPackLocation (String packName)
Returns the location of the specified AI pack on the device or null
if this pack is not
downloaded.
The files found at this path should not be modified.
Parameters | |
---|---|
packName |
String |
Returns | |
---|---|
AiPackLocation |
getPackLocations
public abstract Map<String, AiPackLocation> getPackLocations ()
Returns the location of all installed AI packs as a mapping from the AI pack name to an AiPackLocation
.
The files found at these paths should not be modified.
Returns | |
---|---|
Map<String, AiPackLocation> |
getPackStates
public abstract Task<AiPackStates> getPackStates (List<String> packNames)
Requests download state or details for the specified AI packs.
Do not use this method to determine whether an AI pack is downloaded. Instead use getPackLocation(String)
.
Parameters | |
---|---|
packNames |
List |
Returns | |
---|---|
Task<AiPackStates> |
registerListener
public abstract void registerListener (AiPackStateUpdateListener listener)
Registers a listener that will be notified of changes to the state of pack downloads for this
app. Listeners should be subsequently unregistered using unregisterListener(AiPackStateUpdateListener)
.
Parameters | |
---|---|
listener |
AiPackStateUpdateListener |
removePack
public abstract Task<Void> removePack (String packName)
Deletes the specified AI pack from the internal storage of the app.
Use this method to delete AI packs instead of deleting files manually. This ensures that the AI Pack will not be re-downloaded during an app update.
If the AI pack is currently being downloaded or installed, this method does not cancel the
process. For this case, use cancel(List
instead.
Parameters | |
---|---|
packName |
String |
Returns | |
---|---|
Task<Void> |
A task that will be successful only if files were successfully deleted. |
showConfirmationDialog
public abstract boolean showConfirmationDialog (ActivityResultLauncher<IntentSenderRequest> activityResultLauncher)
Shows a dialog that asks the user for consent to download packs that are currently in either
the AiPackStatus.REQUIRES_USER_CONFIRMATION
state or the AiPackStatus.WAITING_FOR_WIFI
state.
If the app has not been installed by Play, an update may be triggered to ensure that a valid version is installed. This will cause the app to restart and all pack requests to be cancelled. These packs should be requested again after the app restarts.
The confirmation activity returns one of the following values:
Activity.RESULT_OK
if the user accepted.Activity.RESULT_CANCELED
if the user denied or the dialog has been closed in any other way (e.g. backpress).
Parameters | |
---|---|
activityResultLauncher |
ActivityResultLauncher : an activityResultLauncher to launch the confirmation dialog. |
Returns | |
---|---|
boolean |
whether the confirmation dialog has been started. |
unregisterListener
public abstract void unregisterListener (AiPackStateUpdateListener listener)
Unregisters a listener previously added using registerListener(AiPackStateUpdateListener)
.
Parameters | |
---|---|
listener |
AiPackStateUpdateListener |