com.google.android.play.core.ktx

Classes

AppUpdateResult

Result type that will be emmited 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.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 buffered Flow 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
Int

Returns the progress status of the update.

Boolean

Returns true if flexible update is allowed.

Boolean

Returns true if immediate update is allowed.

For com.google.android.play.core.install.InstallState
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.

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

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

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

requestInstall

@ExperimentalCoroutinesApi 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

requestProgressFlow

@ExperimentalCoroutinesApi fun SplitInstallManager.requestProgressFlow(): Flow<SplitInstallSessionState>

Creates and returns a buffered Flow 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

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

@ExperimentalCoroutinesApi 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 An intent you use start an update. You get this using AppUpdateManager.getAppUpdateInfo.
appUpdateType A value from AppUpdateType that determines the type of update flow.
fragment the Fragment that will be used for Fragment.onActivityResult
requestCode the request code that will be used for Fragment.onActivityResult

Extension properties

bytesDownloaded

val SplitInstallSessionState.bytesDownloaded: Long

The bytes downloaded by this update.

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.

packageName

val InstallState.packageName: String!

Returns the package name for the app being installed.

sessionId

val SplitInstallSessionState.sessionId: Int

The session id of this update.

status

val SplitInstallSessionState.status: Int

The status code of this update.

totalBytesToDownload

val SplitInstallSessionState.totalBytesToDownload: Long

The total bytes to download by this update.