Created
January 2, 2021 04:20
-
-
Save gb103/ed26e19ff750dc633dc1dc96a8abb067 to your computer and use it in GitHub Desktop.
Handle error in the dynamic feature download
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() | |
... | |
} | |
} | |
fun checkForActiveDownloads() { | |
splitInstallManager | |
// Returns a SplitInstallSessionState object for each active session as a List. | |
.sessionStates | |
.addOnCompleteListener { task -> | |
if (task.isSuccessful) { | |
// Check for active sessions. | |
for (state in task.result) { | |
if (state.status() == SplitInstallSessionStatus.DOWNLOADING) { | |
// Cancel the request, or request a deferred installation. | |
} | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment