ModuleInstallClient

public interface ModuleInstallClient implements HasApiKey<Api.ApiOptions.NoOptions>

Interface for module install APIs.

Public Method Summary

abstract Task<ModuleAvailabilityResponse>
areModulesAvailable(OptionalModuleApi... apis)
Checks if the optional modules required by the OptionalModuleApi are already present on device.
abstract Task<Void>
deferredInstall(OptionalModuleApi... apis)
Defers installation of optional modules required by the OptionalModuleApi.
abstract Task<ModuleInstallIntentResponse>
getInstallModulesIntent(OptionalModuleApi... apis)
Gets the ModuleInstallIntentResponse that includes a PendingIntent to initiate the optional module download and installation flow.
abstract Task<ModuleInstallResponse>
installModules(ModuleInstallRequest request)
Triggers an immediate installation request from a ModuleInstallRequest.
abstract Task<Void>
releaseModules(OptionalModuleApi... apis)
Initiates a request to release optional modules required by OptionalModuleApi when they are no longer needed.
abstract Task<Boolean>
unregisterListener(InstallStatusListener listener)
Unregisters a listener you previously set in ModuleInstallRequest.

Public Methods

public abstract Task<ModuleAvailabilityResponse> areModulesAvailable (OptionalModuleApi... apis)

Checks if the optional modules required by the OptionalModuleApi are already present on device.

This method is intended to be used in cases where you don't want to unconditionally trigger an immediate installation if the modules aren't available already. If you need to trigger an immediate installation, use installModules(ModuleInstallRequest) instead.

Parameters
apis the OptionalModuleApis that require optional modules.
Returns

public abstract Task<Void> deferredInstall (OptionalModuleApi... apis)

Defers installation of optional modules required by the OptionalModuleApi. When called, Google Play services will optimize the best time to install those modules in the background.

If your app requires immediate access to those modules, use installModules(ModuleInstallRequest) to install the optional modules right away.

Parameters
apis the OptionalModuleApis that require optional modules.
Returns
  • a successful Task if the deferred install request is received.

public abstract Task<ModuleInstallIntentResponse> getInstallModulesIntent (OptionalModuleApi... apis)

Gets the ModuleInstallIntentResponse that includes a PendingIntent to initiate the optional module download and installation flow.

Parameters
apis the OptionalModuleApis that require optional modules.
Returns

public abstract Task<ModuleInstallResponse> installModules (ModuleInstallRequest request)

Triggers an immediate installation request from a ModuleInstallRequest.

The Task completes once the ModuleInstallRequest has been initiated. This method does not wait for installation to complete. To monitor the install/download progress of the request, set a InstallStatusListener when building the ModuleInstallRequest to receive ModuleInstallStatusUpdate, and make sure to unregisterListener(InstallStatusListener) once the installation completes. The listener is only registered if the modules requested are not already installed.

The ModuleInstallResponse indicates whether the modules are already installed and contains an integer session id that is corresponding to a unique install request. A session id of 0 and/or ModuleInstallResponse.areModulesAlreadyInstalled() returned true indicate that the optional modules are already installed. You don't need to interact with session id unless the same InstallStatusListener object is used in multiple ModuleInstallRequests.

Parameters
request the ModuleInstallRequest you build for the install request.
Returns

public abstract Task<Void> releaseModules (OptionalModuleApi... apis)

Initiates a request to release optional modules required by OptionalModuleApi when they are no longer needed.

This method notifies Google Play services that the optional modules are no longer needed for this app, but it does not guarantee the optional modules can be removed. Google Play services will try to clean up the optional modules when they are not used by any apps.

If this method is called when an install request with all the specified modules is pending, this method will do the best-effort to cancel that install request. You can monitor the ModuleInstallStatusUpdate through InstallStatusListener to listen for the ModuleInstallStatusUpdate.InstallState.STATE_CANCELED state when the install request is canceled.

Parameters
apis the OptionalModuleApis that require optional modules.
Returns
  • a successful Task if the release modules request is received.

public abstract Task<Boolean> unregisterListener (InstallStatusListener listener)

Unregisters a listener you previously set in ModuleInstallRequest.

Parameters
listener the same InstallStatusListener that is set in the ModuleInstallRequest.
Returns
  • true if the given listener was found and unregistered, false otherwise.