Skip to content

Instantly share code, notes, and snippets.

@gb103
Created January 2, 2021 04:30
Show Gist options
  • Save gb103/d72751036eb79c8d7dce7fa13a115557 to your computer and use it in GitHub Desktop.
Save gb103/d72751036eb79c8d7dce7fa13a115557 to your computer and use it in GitHub Desktop.
Access installed module
// Generate a new context as soon as a request for a new module
// reports as INSTALLED.
override fun onStateUpdate(state: SplitInstallSessionState ) {
if (state.sessionId() == mySessionId) {
when (state.status()) {
...
SplitInstallSessionStatus.INSTALLED -> {
val newContext = context.createPackageContext(context.packageName, 0)
// If you use AssetManager to access your app’s raw asset files, you’ll need
// to generate a new AssetManager instance from the updated context.
val am = newContext.assets
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment