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() |
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
splitInstallManager | |
.startInstall(request) | |
.addOnFailureListener { exception -> | |
when ((exception as SplitInstallException).errorCode) { | |
SplitInstallErrorCode.NETWORK_ERROR -> { | |
// Display a message that requests the user to establish a | |
// network connection. | |
} | |
SplitInstallErrorCode.ACTIVE_SESSIONS_LIMIT_EXCEEDED -> checkForActiveDownloads() | |
... |
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
// Initializes a variable to later track the session ID for a given request. | |
var mySessionId = 0 | |
// Creates a listener for request status updates. | |
val listener = SplitInstallStateUpdatedListener { state -> | |
if (state.sessionId() == mySessionId) { | |
// Read the status of the request to handle the state update. | |
} | |
} |
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
// Creates an instance of SplitInstallManager. | |
val splitInstallManager = SplitInstallManagerFactory.create(context) | |
// Creates a request to install a module. | |
val request = | |
SplitInstallRequest | |
.newBuilder() | |
// You can download multiple on demand modules per | |
// request by invoking the following method for each | |
// module you want to install. |
NewerOlder