Google is committed to advancing racial equity for Black communities. See how.

com.google.android.play.core.ktx

Classes

AppUpdateResult

Result type that will be emitted from requestUpdateFlow for various stages of the update.

Top-level functions summary

SplitInstallStateUpdatedListener
SplitInstallStateUpdatedListener(onRequiresConfirmation: (SplitInstallSessionState) -> Unit, onInstalled: (SplitInstallSessionState) -> Unit, onFailed: (SplitInstallSessionState) -> Unit = {}, onPending: (SplitInstallSessionState) -> Unit = {}, onDownloaded: (SplitInstallSessionState) -> Unit = {}, onDownloading: (SplitInstallSessionState) -> Unit = {}, onInstalling: (SplitInstallSessionState) -> Unit = {}, onCanceling: (SplitInstallSessionState) -> Unit = {}, onCanceled: (SplitInstallSessionState) -> Unit = {}, onNonTerminalStatus: (SplitInstallSessionState) -> Unit = {}, onTerminalStatus: (SplitInstallSessionState) -> Unit = {})

A convenience function for creating a SplitInstallStateUpdatedListener.

Extension functions summary

For com.google.android.play.core.appupdate.AppUpdateManager
suspend AppUpdateInfo

Requests the update availability for the current app

suspend Unit

For a flexible update flow, triggers the completion of the update.

Flow<AppUpdateResult>

Entry point for monitoring the availability and progress of updates.

Boolean
AppUpdateManager.startUpdateFlowForResult(appUpdateInfo: AppUpdateInfo, appUpdateType: Int, fragment: Fragment, requestCode: Int)

A version of AppUpdateManager.startUpdateFlowForResult that accepts an AndroidX Fragment for returning the result.

For com.google.android.play.core.assetpacks.AssetPackManager
suspend Int

Suspend version of AssetPackManager.showCellularDataConfirmation

suspend AssetPackStates

Requests to download the specified asset packs.

suspend AssetPackStates

Suspend version of AssetPackManager.getPackStates

Flow<AssetPackState>

Creates and returns a Flow with a Channel.UNLIMITED buffer that will deliver all progress events for the specified asset packs installations.

suspend Unit

Suspend version of AssetPackManager.removePack

For com.google.android.play.core.review.ReviewManager
suspend Unit
ReviewManager.launchReview(activity: Activity, reviewInfo: ReviewInfo)

Suspending version of ReviewManager.launchReviewFlow.

suspend ReviewInfo

Suspending version of ReviewManager.requestReviewFlow.

For com.google.android.play.core.splitinstall.SplitInstallManager
suspend Unit

Suspend version of SplitInstallManager.cancelInstall

suspend Unit

Suspend version of SplitInstallManager.deferredInstall

suspend Unit

Suspend version of SplitInstallManager.deferredLanguageInstall

suspend Unit

Suspend version of SplitInstallManager.deferredLanguageUninstall

suspend Unit

Suspend version of SplitInstallManager.deferredUninstall

suspend Int
SplitInstallManager.requestInstall(modules: List<String> = listOf(), languages: List<String> = listOf())

Initiates installation of the requested modules/languages.

Flow<SplitInstallSessionState>

Creates and returns a Flow with a Channel.UNLIMITED buffer that will deliver all progress events for ongoing split installations.

suspend SplitInstallSessionState

Suspend version of SplitInstallManager.getSessionState

suspend List<SplitInstallSessionState>

Suspend version of SplitInstallManager.getSessionStates

Boolean
SplitInstallManager.startConfirmationDialogForResult(sessionState: SplitInstallSessionState, fragment: Fragment, requestCode: Int)

A version of SplitInstallManager.startConfirmationDialogForResult that accepts an AndroidX Fragment for returning the result.

Extension properties summary

For com.google.android.play.core.appupdate.AppUpdateInfo
Long

The number of bytes downloaded so far.

Int?

If an update is available or in progress, this method returns the number of days since the Google Play Store app on the user's device has learnt about an available update.

Int

Returns the progress status of the update.

Boolean

Returns true if flexible update is allowed.

Boolean

Returns true if immediate update is allowed.

Long

The total number of bytes to be downloaded for this update.

Int

Returns the in-app update priority for this update, as defined by the developer in the Google Play Developer API.

For com.google.android.play.core.assetpacks.AssetLocation
Long

The file offset where the asset starts, in bytes.

String

The path to the file containing the asset.

Long

The size of the asset, in bytes.

For com.google.android.play.core.assetpacks.AssetPackLocation
String?

The file path to the folder containing the asset pack's unpackaged assets, if the storage method is AssetPackStorageMethod.STORAGE_FILES.

Int

Whether the pack is installed as an APK or unpackaged into a folder on the filesystem.

String?

Returns the file path to the folder containing the unpackaged asset pack, if the storage method is AssetPackStorageMethod.STORAGE_FILES.

For com.google.android.play.core.assetpacks.AssetPackState
Long

The total number of bytes already downloaded for the pack.

Int

The error code for the pack, if Play has failed to download the pack.

String

The name of the pack.

Int

The download status of the pack.

Long

The total size of the pack in bytes.

Int

Returns the percentage of the asset pack already transferred to the app.

For com.google.android.play.core.assetpacks.AssetPackStates
Map<String, AssetPackState>

Map from pack name to AssetPackState.

Long

Total size of all requested packs in bytes.

For com.google.android.play.core.install.InstallState
Long

The number of bytes downloaded so far.

Boolean

This signifies that this is a terminal status (there will be no more updates) and should be handled accordingly (success, cancellation or failure).

Int

Returns the error code for an install, or {@link InstallErrorCode#NO_ERROR}.

Int

Returns the status of an install.

String

Returns the package name for the app being installed.

Long

The total number of bytes to be downloaded for this update.

For com.google.android.play.core.splitinstall.SplitInstallSessionState
Long

The bytes downloaded by this update.

Int

The error code of this update.

Boolean

Signifies that this update is terminal, meaning there will be no more updates for this session.

List<String>

The languages included by this update.

List<String>

The modules included by this update.

Int

The session id of this update.

Int

The status code of this update.

Long

The total bytes to download by this update.

Top-level functions

SplitInstallStateUpdatedListener

fun SplitInstallStateUpdatedListener(
    onRequiresConfirmation: (SplitInstallSessionState) -> Unit,
    onInstalled: (SplitInstallSessionState) -> Unit,
    onFailed: (SplitInstallSessionState) -> Unit = {},
    onPending: (SplitInstallSessionState) -> Unit = {},
    onDownloaded: (SplitInstallSessionState) -> Unit = {},
    onDownloading: (SplitInstallSessionState) -> Unit = {},
    onInstalling: (SplitInstallSessionState) -> Unit = {},
    onCanceling: (SplitInstallSessionState) -> Unit = {},
    onCanceled: (SplitInstallSessionState) -> Unit = {},
    onNonTerminalStatus: (SplitInstallSessionState) -> Unit = {},
    onTerminalStatus: (SplitInstallSessionState) -> Unit = {}
): SplitInstallStateUpdatedListener

A convenience function for creating a SplitInstallStateUpdatedListener.

The required states to handle are onRequiresConfirmation, where you should start a confirmation request using SplitInstallManager.startConfirmationDialogForResult, and onInstalled where you can start using the installed module.

All other arguments are optional and correspond with the SplitInstallSessionStatus codes.

There are two special arguments (also optional): onNonTerminalStatus and onTerminalStatus, which will be called in addition to the normal status codes. The first is called for all progress (non-terminal) status codes, while the latter for statuses that would return true for SplitInstallSessionState.hasTerminalStatus, i.e. failure, cancellation and completion.

Extension functions

launchReview

suspend fun ReviewManager.launchReview(
    activity: Activity,
    reviewInfo: ReviewInfo
): Unit

Suspending version of ReviewManager.launchReviewFlow.

Launches and displays the review flow to the user.

In some circumstances the review flow will not be shown to the user, e.g. they have already seen it recently, so do not assume that calling this method will always display the review dialog.

App should resume when this returns.

requestAppUpdateInfo

suspend fun AppUpdateManager.requestAppUpdateInfo(): AppUpdateInfo

Requests the update availability for the current app

requestCancelInstall

suspend fun SplitInstallManager.requestCancelInstall(sessionId: Int): Unit

Suspend version of SplitInstallManager.cancelInstall

requestCellularDataConfirmation

suspend fun AssetPackManager.requestCellularDataConfirmation(activity: Activity): Int

Suspend version of AssetPackManager.showCellularDataConfirmation

requestCompleteUpdate

suspend fun AppUpdateManager.requestCompleteUpdate(): Unit

For a flexible update flow, triggers the completion of the update.

requestDeferredInstall

suspend fun SplitInstallManager.requestDeferredInstall(moduleNames: List<String>): Unit

Suspend version of SplitInstallManager.deferredInstall

requestDeferredLanguageInstall

suspend fun SplitInstallManager.requestDeferredLanguageInstall(languages: List<Locale>): Unit

Suspend version of SplitInstallManager.deferredLanguageInstall

requestDeferredLanguageUninstall

suspend fun SplitInstallManager.requestDeferredLanguageUninstall(languages: List<Locale>): Unit

Suspend version of SplitInstallManager.deferredLanguageUninstall

requestDeferredUninstall

suspend fun SplitInstallManager.requestDeferredUninstall(moduleNames: List<String>): Unit

Suspend version of SplitInstallManager.deferredUninstall

requestFetch

suspend fun AssetPackManager.requestFetch(packs: List<String>): AssetPackStates

Requests to download the specified asset packs.

Return
the AssetPackStates for the requested asset packs
Exceptions
AssetPackException in case of errors

requestInstall

suspend fun SplitInstallManager.requestInstall(
    modules: List<String> = listOf(),
    languages: List<String> = listOf()
): Int

Initiates installation of the requested modules/languages.

Return
the sessionId for the installation if successful
Exceptions
com.google.android.play.core.splitinstall.SplitInstallException in case of errors

requestPackStates

suspend fun AssetPackManager.requestPackStates(packs: List<String>): AssetPackStates

Suspend version of AssetPackManager.getPackStates

requestProgressFlow

fun AssetPackManager.requestProgressFlow(packs: List<String>): Flow<AssetPackState>

Creates and returns a Flow with a Channel.UNLIMITED buffer that will deliver all progress events for the specified asset packs installations.

Exceptions
AssetPackException in case of errors
Return
Flow that emits progress events for asset pack installations

requestProgressFlow

fun SplitInstallManager.requestProgressFlow(): Flow<SplitInstallSessionState>

Creates and returns a Flow with a Channel.UNLIMITED buffer that will deliver all progress events for ongoing split installations.

Will clean up any listeners on the SplitInstallManager when cancelled.

Exceptions
com.google.android.play.core.splitinstall.SplitInstallException in case of errors
Return
Flow that emits progress events for split installations

requestRemovePack

suspend fun AssetPackManager.requestRemovePack(packName: String): Unit

Suspend version of AssetPackManager.removePack

requestReview

suspend fun ReviewManager.requestReview(): ReviewInfo

Suspending version of ReviewManager.requestReviewFlow.

Retrieves all the needed information to launch the review flow.

Needs to be called before launchReview to obtain an ReviewInfo object which is used to launch the review flow.

requestSessionState

suspend fun SplitInstallManager.requestSessionState(sessionId: Int): SplitInstallSessionState

Suspend version of SplitInstallManager.getSessionState

requestSessionStates

suspend fun SplitInstallManager.requestSessionStates(): List<SplitInstallSessionState>

Suspend version of SplitInstallManager.getSessionStates

requestUpdateFlow

fun AppUpdateManager.requestUpdateFlow(): Flow<AppUpdateResult>

Entry point for monitoring the availability and progress of updates. Creates and returns a Flow that will emit events of type AppUpdateResult, which can be one of:

The returned Flow is using Channel.CONFLATED, meaning it will emit only the latest status.

Exceptions
InstallException when there was a problem getting or installing updates

startConfirmationDialogForResult

fun SplitInstallManager.startConfirmationDialogForResult(
    sessionState: SplitInstallSessionState,
    fragment: Fragment,
    requestCode: Int
): Boolean

A version of SplitInstallManager.startConfirmationDialogForResult that accepts an AndroidX Fragment for returning the result.

startUpdateFlowForResult

fun AppUpdateManager.startUpdateFlowForResult(
    appUpdateInfo: AppUpdateInfo,
    appUpdateType: Int,
    fragment: Fragment,
    requestCode: Int
): Boolean

A version of AppUpdateManager.startUpdateFlowForResult that accepts an AndroidX Fragment for returning the result.

Parameters
appUpdateInfo: AppUpdateInfo An intent you use start an update. You get this using AppUpdateManager.getAppUpdateInfo.
appUpdateType: Int A value from AppUpdateType that determines the type of update flow.
fragment: Fragment the Fragment that will be used for Fragment.onActivityResult
requestCode: Int the request code that will be used for Fragment.onActivityResult

Extension properties

assetsPath

val AssetPackLocation.assetsPath: String?

The file path to the folder containing the asset pack's unpackaged assets, if the storage method is AssetPackStorageMethod.STORAGE_FILES.

The files found in this path should not be modified.

If the storage method is AssetPackStorageMethod.APK_ASSETS, this contains null. To access assets from packs installed as APKs, use Asset Manager.

bytesDownloaded

val AppUpdateInfo.bytesDownloaded: Long

The number of bytes downloaded so far.

The return value is defined only if installStatus returns InstallStatus.DOWNLOADING

bytesDownloaded

val AssetPackState.bytesDownloaded: Long

The total number of bytes already downloaded for the pack.

bytesDownloaded

val InstallState.bytesDownloaded: Long

The number of bytes downloaded so far.

The return value is defined only if installStatus returns InstallStatus.DOWNLOADING

bytesDownloaded

val SplitInstallSessionState.bytesDownloaded: Long

The bytes downloaded by this update.

clientVersionStalenessDays

val AppUpdateInfo.clientVersionStalenessDays: Int?

If an update is available or in progress, this method returns the number of days since the Google Play Store app on the user's device has learnt about an available update.

If update is not available, or if staleness information is unavailable, this method returns null.

errorCode

val AssetPackState.errorCode: Int

The error code for the pack, if Play has failed to download the pack.

AssetPackErrorCode.NO_ERROR if the download was successful or is in progress or has not been attempted.

errorCode

val SplitInstallSessionState.errorCode: Int

The error code of this update.

hasTerminalStatus

val InstallState.hasTerminalStatus: Boolean

This signifies that this is a terminal status (there will be no more updates) and should be handled accordingly (success, cancellation or failure).

hasTerminalStatus

val SplitInstallSessionState.hasTerminalStatus: Boolean

Signifies that this update is terminal, meaning there will be no more updates for this session.

It should be handled appropriately (cancellation, failure or completion).

installErrorCode

val InstallState.installErrorCode: Int

Returns the error code for an install, or {@link InstallErrorCode#NO_ERROR}.

Return
a value from {@link InstallStatus}

installStatus

val AppUpdateInfo.installStatus: Int

Returns the progress status of the update.

installStatus

val InstallState.installStatus: Int

Returns the status of an install.

Return
a value from {@link InstallStatus}

isFlexibleUpdateAllowed

val AppUpdateInfo.isFlexibleUpdateAllowed: Boolean

Returns true if flexible update is allowed.

isImmediateUpdateAllowed

val AppUpdateInfo.isImmediateUpdateAllowed: Boolean

Returns true if immediate update is allowed.

languages

val SplitInstallSessionState.languages: List<String>

The languages included by this update.

moduleNames

val SplitInstallSessionState.moduleNames: List<String>

The modules included by this update.

name

val AssetPackState.name: String

The name of the pack.

offset

val AssetLocation.offset: Long

The file offset where the asset starts, in bytes.

packStates

val AssetPackStates.packStates: Map<String, AssetPackState>

Map from pack name to AssetPackState.

packStorageMethod

val AssetPackLocation.packStorageMethod: Int

Whether the pack is installed as an APK or unpackaged into a folder on the filesystem.

packageName

val InstallState.packageName: String

Returns the package name for the app being installed.

path

val AssetLocation.path: String

The path to the file containing the asset.

path

val AssetPackLocation.path: String?

Returns the file path to the folder containing the unpackaged asset pack, if the storage method is AssetPackStorageMethod.STORAGE_FILES.

The files found in this path should not be modified.

If the storage method is AssetPackStorageMethod.APK_ASSETS, this method will return null. To access assets from packs installed as APKs, use Asset Manager.

sessionId

val SplitInstallSessionState.sessionId: Int

The session id of this update.

size

val AssetLocation.size: Long

The size of the asset, in bytes.

status

val AssetPackState.status: Int

The download status of the pack.

status

val SplitInstallSessionState.status: Int

The status code of this update.

totalBytes

val AssetPackStates.totalBytes: Long

Total size of all requested packs in bytes.

totalBytesToDownload

val AppUpdateInfo.totalBytesToDownload: Long

The total number of bytes to be downloaded for this update.

The return value is defined only if installStatus returns InstallStatus.DOWNLOADING

totalBytesToDownload

val AssetPackState.totalBytesToDownload: Long

The total size of the pack in bytes.

totalBytesToDownload

val InstallState.totalBytesToDownload: Long

The total number of bytes to be downloaded for this update.

The return value is defined only if installStatus returns InstallStatus.DOWNLOADING

totalBytesToDownload

val SplitInstallSessionState.totalBytesToDownload: Long

The total bytes to download by this update.

transferProgressPercentage

val AssetPackState.transferProgressPercentage: Int

Returns the percentage of the asset pack already transferred to the app.

This value is only defined when the status is AssetPackStatus.TRANSFERRING

updatePriority

val AppUpdateInfo.updatePriority: Int

Returns the in-app update priority for this update, as defined by the developer in the Google Play Developer API.

The return value is defined only if updateAvailability returns UpdateAvailability.UPDATE_AVAILABLE.