Stay organized with collections
Save and categorize content based on your preferences.
SessionCallback
abstract class SessionCallback
Events for observing session lifecycle.
A typical session lifecycle looks like this:
- An installer creates a session to indicate pending app delivery. All install details are available at this point.
- The installer opens the session to deliver APK data. Note that a session may be opened and closed multiple times as network connectivity changes. The installer may deliver periodic progress updates.
- The installer commits or abandons the session, resulting in the session being finished.
Summary
Public methods |
abstract Unit |
Active state for session has been changed.
|
abstract Unit |
Badging details for an existing session has changed.
|
abstract Unit |
New session has been created.
|
abstract Unit |
Session has completely finished, either with success or failure.
|
abstract Unit |
Progress for given session has been updated.
|
Public constructors
SessionCallback
SessionCallback()
Public methods
onActiveChanged
abstract fun onActiveChanged(
sessionId: Int,
active: Boolean
): Unit
Active state for session has been changed.
A session is considered active whenever there is ongoing forward progress being made, such as the installer holding an open Session
instance while streaming data into place, or the system optimizing code as the result of Session.commit(IntentSender)
.
If the installer closes the Session
without committing, the session is considered inactive until the installer opens the session again.
onBadgingChanged
abstract fun onBadgingChanged(sessionId: Int): Unit
Badging details for an existing session has changed. For example, the app icon or label has been updated.
onFinished
abstract fun onFinished(
sessionId: Int,
success: Boolean
): Unit
Session has completely finished, either with success or failure.
onProgressChanged
abstract fun onProgressChanged(
sessionId: Int,
progress: Float
): Unit
Progress for given session has been updated.
Note that this progress may not directly correspond to the value reported by PackageInstaller.Session.setStagingProgress(float)
, as the system may carve out a portion of the overall progress to represent its own internal installation work.
Content and code samples on this page are subject to the licenses described in the Content License. Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.
Last updated 2025-02-10 UTC.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-02-10 UTC."],[],[],null,["# PackageInstaller.SessionCallback\n\nAdded in [API level 21](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)\n\nSessionCallback\n===============\n\n*** ** * ** ***\n\nKotlin \\|[Java](/reference/android/content/pm/PackageInstaller.SessionCallback \"View this page in Java\") \n\n```\nabstract class SessionCallback\n```\n\n|---|----------------------------------------------------------|\n| [kotlin.Any](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-any/index.html) ||\n| ↳ | [android.content.pm.PackageInstaller.SessionCallback](#) |\n\nEvents for observing session lifecycle.\n\nA typical session lifecycle looks like this:\n\n- An installer creates a session to indicate pending app delivery. All install details are available at this point.\n- The installer opens the session to deliver APK data. Note that a session may be opened and closed multiple times as network connectivity changes. The installer may deliver periodic progress updates.\n- The installer commits or abandons the session, resulting in the session being finished.\n\nSummary\n-------\n\n| Public constructors ||\n|--------------------------------------------------|---|\n| [SessionCallback](#SessionCallback())`()` \u003cbr /\u003e |\n\n| Public methods ||\n|---------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| abstract [Unit](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html) | [onActiveChanged](#onActiveChanged(kotlin.Int,%20kotlin.Boolean))`(`sessionId:` `[Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)`, `active:` `[Boolean](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html)`)` Active state for session has been changed. |\n| abstract [Unit](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html) | [onBadgingChanged](#onBadgingChanged(kotlin.Int))`(`sessionId:` `[Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)`)` Badging details for an existing session has changed. |\n| abstract [Unit](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html) | [onCreated](#onCreated(kotlin.Int))`(`sessionId:` `[Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)`)` New session has been created. |\n| abstract [Unit](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html) | [onFinished](#onFinished(kotlin.Int,%20kotlin.Boolean))`(`sessionId:` `[Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)`, `success:` `[Boolean](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html)`)` Session has completely finished, either with success or failure. |\n| abstract [Unit](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html) | [onProgressChanged](#onProgressChanged(kotlin.Int,%20kotlin.Float))`(`sessionId:` `[Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)`, `progress:` `[Float](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-float/index.html)`)` Progress for given session has been updated. |\n\nPublic constructors\n-------------------\n\n### SessionCallback\n\n```\nSessionCallback()\n```\n\nPublic methods\n--------------\n\n### onActiveChanged\n\nAdded in [API level 21](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels) \n\n```\nabstract fun onActiveChanged(\n sessionId: Int, \n active: Boolean\n): Unit\n```\n\nActive state for session has been changed.\n\nA session is considered active whenever there is ongoing forward progress being made, such as the installer holding an open [Session](/reference/kotlin/android/content/pm/PackageInstaller.Session) instance while streaming data into place, or the system optimizing code as the result of [Session.commit(IntentSender)](/reference/kotlin/android/content/pm/PackageInstaller.Session#commit(android.content.IntentSender)).\n\nIf the installer closes the [Session](/reference/kotlin/android/content/pm/PackageInstaller.Session) without committing, the session is considered inactive until the installer opens the session again. \n\n### onBadgingChanged\n\nAdded in [API level 21](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels) \n\n```\nabstract fun onBadgingChanged(sessionId: Int): Unit\n```\n\nBadging details for an existing session has changed. For example, the app icon or label has been updated. \n\n### onCreated\n\nAdded in [API level 21](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels) \n\n```\nabstract fun onCreated(sessionId: Int): Unit\n```\n\nNew session has been created. Details about the session can be obtained from [PackageInstaller.getSessionInfo(int)](/reference/kotlin/android/content/pm/PackageInstaller#getSessionInfo(kotlin.Int)). \n\n### onFinished\n\nAdded in [API level 21](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels) \n\n```\nabstract fun onFinished(\n sessionId: Int, \n success: Boolean\n): Unit\n```\n\nSession has completely finished, either with success or failure. \n\n### onProgressChanged\n\nAdded in [API level 21](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels) \n\n```\nabstract fun onProgressChanged(\n sessionId: Int, \n progress: Float\n): Unit\n```\n\nProgress for given session has been updated.\n\nNote that this progress may not directly correspond to the value reported by [PackageInstaller.Session.setStagingProgress(float)](/reference/kotlin/android/content/pm/PackageInstaller.Session#setStagingProgress(kotlin.Float)), as the system may carve out a portion of the overall progress to represent its own internal installation work."]]