Last active
January 2, 2021 03:49
-
-
Save gb103/24588d3f09d8684412afc0699da635ff to your computer and use it in GitHub Desktop.
Monitor the install progress
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. | |
} | |
} | |
// Registers the listener. | |
splitInstallManager.registerListener(listener) | |
... | |
splitInstallManager | |
.startInstall(request) | |
// When the platform accepts your request to download | |
// an on demand module, it binds it to the following session ID. | |
// You use this ID to track further status updates for the request. | |
.addOnSuccessListener { sessionId -> mySessionId = sessionId } | |
// You should also add the following listener to handle any errors | |
// processing the request. | |
.addOnFailureListener { exception -> | |
// Handle request errors. | |
} | |
// When your app no longer requires further updates, unregister the listener. | |
splitInstallManager.unregisterListener(listener) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment