The Android Developer Challenge is back! Submit your idea before December 2.

SplitInstallManager

public interface SplitInstallManager

com.google.android.play.core.splitinstall.SplitInstallManager
Known Indirect Subclasses


Manages sessions for requesting and installing split APKs for additional features or language resources.

To learn more, read Request an on demand module.

Summary

Public methods

abstract Task<Void> cancelInstall(int sessionId)

Starts a request to cancel a pending split install.

abstract Task<Void> deferredInstall(List<String> moduleNames)

Defers installation of given moduleNames.

abstract Task<Void> deferredLanguageInstall(List<Locale> languages)

Defers installation of given languages.

abstract Task<Void> deferredLanguageUninstall(List<Locale> languages)

Defers uninstallation of given languages.

abstract Task<Void> deferredUninstall(List<String> moduleNames)

Defers uninstallation of given moduleNames.

abstract Set<String> getInstalledLanguages()

Returns the languages that are currently installed.

abstract Set<String> getInstalledModules()

Returns the modules that are currently installed (excluding the base module).

abstract Task<SplitInstallSessionState> getSessionState(int sessionId)

Returns the current state of a split install session.

abstract Task<List<SplitInstallSessionState>> getSessionStates()

Returns the state for all active sessions belonging to the app.

abstract void registerListener(SplitInstallStateUpdatedListener listener)

Registers a listener for your app that is alerted of state changes for module install requests.

abstract boolean startConfirmationDialogForResult(SplitInstallSessionState sessionState, Activity activity, int requestCode)

Starts the user confirmation dialog from the provided SplitInstallSessionState.

abstract Task<Integer> startInstall(SplitInstallRequest request)

Initiates a request to download and install split APKs for additional features or language resources.

abstract void unregisterListener(SplitInstallStateUpdatedListener listener)

Unregisters a listener you previously registered using registerListener(SplitInstallStateUpdatedListener).

Public methods

cancelInstall

Task<Void> cancelInstall (int sessionId)

Starts a request to cancel a pending split install.

Cancelling requests are best-effort. You can monitor the request state to listening for the CANCELED state.

Parameters
sessionId int: the sessionId of the request you would like to cancel.

Returns
Task<Void>

deferredInstall

Task<Void> deferredInstall (List<String> moduleNames)

Defers installation of given moduleNames. When called, the Play Store tries to eventually install those modules in the background.

If your app requires immediate access to a module, request to install the module in the foreground.

To learn more, read Defer installation of on demand modules.

Parameters
moduleNames List: the names of the modules you want to install in the background.

Returns
Task<Void>

deferredLanguageInstall

Task<Void> deferredLanguageInstall (List<Locale> languages)

Defers installation of given languages. When called, the Play Store tries to eventually install those languages in the background.

To learn more, read Download additional language resources.

Parameters
languages List: the languages you want to install in the background.

Returns
Task<Void>

deferredLanguageUninstall

Task<Void> deferredLanguageUninstall (List<Locale> languages)

Defers uninstallation of given languages. When called, the Play Store tries to eventually uninstall these languages from the app in the background.

To learn more, read Uninstall additional language resources.

Parameters
languages List: the languages you want to uninstall in the background.

Returns
Task<Void>

deferredUninstall

Task<Void> deferredUninstall (List<String> moduleNames)

Defers uninstallation of given moduleNames. When called, the Play Store tries to eventually remove those modules in the background.

These moduleNames will not be included when the app is updated, even if they are marked as available at install-time in the updated version of the app. For the app to regain access to the modules, the app must request to install the modules agian, or make the module available at install-time under a new module name.

To learn more, read Uninstall modules.

Parameters
moduleNames List: the names of the modules you want to uninstall in the background.

Returns
Task<Void>

getInstalledLanguages

Set<String> getInstalledLanguages ()

Returns the languages that are currently installed.

The app's default language is not included in the returned set.

Returns an empty set if an error occurs.

For Instant Apps, this API is not supported and the return value is undefined.

Note: Languages are considered installed even when they are emulated by ERROR(/SplitCompat) because they are accessible to the app.

Returns
Set<String> the languages that are currently installed.

getInstalledModules

Set<String> getInstalledModules ()

Returns the modules that are currently installed (excluding the base module).

To learn more, read Manage installed modules.

Note: Modules are considered installed even when they are emulated by ERROR(/SplitCompat) because they are accessible to the app.

Returns
Set<String>

getSessionState

Task<SplitInstallSessionState> getSessionState (int sessionId)

Returns the current state of a split install session.

You should not use the session state to determine whether a module is installed. Instead, please use getInstalledModules().

To learn more, read Monitor the request state.

Parameters
sessionId int: the Id for the session you want to status for.

Returns
Task<SplitInstallSessionState>

getSessionStates

Task<List<SplitInstallSessionState>> getSessionStates ()

Returns the state for all active sessions belonging to the app.

You should not use the session state to determine whether a module is installed. Instead, please use getInstalledModules().

To learn more, read Monitor the request state.

Returns
Task<List<SplitInstallSessionState>>

registerListener

void registerListener (SplitInstallStateUpdatedListener listener)

Registers a listener for your app that is alerted of state changes for module install requests.

You should unregister the listener using unregisterListener(SplitInstallStateUpdatedListener) when the request is resolved. To learn more, read Monitor the request state.

Parameters
listener SplitInstallStateUpdatedListener: the SplitInstallStateUpdatedListener you want to register for your app.

startConfirmationDialogForResult

boolean startConfirmationDialogForResult (SplitInstallSessionState sessionState, 
                Activity activity, 
                int requestCode)

Starts the user confirmation dialog from the provided SplitInstallSessionState.

When your app receives a SplitInstallSessionState with status REQUIRES_USER_CONFIRMATION, use this method to obtain consent to download the split via a user confirmation dialog.

This method is run "for result"—analogous to startActivityForResult(Intent, int). The result from the dialog can be handled by the provided activity's ERROR(/Activity#onActivityResult) and is tagged with the provided requestCode.

The dialog returns right after user confirmation, with one of the following values:

To learn more, read Obtain user confirmation.

Parameters
sessionState SplitInstallSessionState: a SplitInstallSessionState with status REQUIRES_USER_CONFIRMATION

activity Activity: the Activity that will be used for ERROR(/Activity#onActivityResult)

requestCode int: the request code that will be used for ERROR(/Activity#onActivityResult)

Returns
boolean whether the session state is a valid and the dialog has been started

Throws
IntentSender.SendIntentException if there is an error when starting the dialog for result

startInstall

Task<Integer> startInstall (SplitInstallRequest request)

Initiates a request to download and install split APKs for additional features or language resources.

To learn more, read Request an on demand module or Download additional language resources.

Parameters
request SplitInstallRequest: the SplitInstallRequest you built for the install request.

Returns
Task<Integer> session id, which can be used to subsequently interact with the session after it is created. A session id of 0 indicates that the splits are already installed; in this case no session is generated.

unregisterListener

void unregisterListener (SplitInstallStateUpdatedListener listener)

Unregisters a listener you previously registered using registerListener(SplitInstallStateUpdatedListener).

Parameters
listener SplitInstallStateUpdatedListener