Created
January 2, 2021 04:22
-
-
Save gb103/67f3c6c37adc2ac609c4ff11f3bcfbcb to your computer and use it in GitHub Desktop.
Handle downloading state updates.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
override fun onStateUpdate(state : SplitInstallSessionState) { | |
if (state.status() == SplitInstallSessionStatus.FAILED | |
&& state.errorCode() == SplitInstallErrorCode.SERVICE_DIES) { | |
// Retry the request. | |
return | |
} | |
if (state.sessionId() == mySessionId) { | |
when (state.status()) { | |
SplitInstallSessionStatus.DOWNLOADING -> { | |
val totalBytes = state.totalBytesToDownload() | |
val progress = state.bytesDownloaded() | |
// Update progress bar. | |
} | |
SplitInstallSessionStatus.INSTALLED -> { | |
// After a module is installed, you can start accessing its content or | |
// fire an intent to start an activity in the installed module. | |
// For other use cases, see access code and resources from installed modules. | |
// If the request is an on demand module for an Android Instant App | |
// running on Android 8.0 (API level 26) or higher, you need to | |
// update the app context using the SplitInstallHelper API. | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment