Added in API level 21

SessionCallback


abstract class SessionCallback
kotlin.Any
   ↳ android.content.pm.PackageInstaller.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 constructors

Public methods
abstract Unit
onActiveChanged(sessionId: Int, active: Boolean)

Active state for session has been changed.

abstract Unit
onBadgingChanged(sessionId: Int)

Badging details for an existing session has changed.

abstract Unit
onCreated(sessionId: Int)

New session has been created.

abstract Unit
onFinished(sessionId: Int, success: Boolean)

Session has completely finished, either with success or failure.

abstract Unit
onProgressChanged(sessionId: Int, progress: Float)

Progress for given session has been updated.

Public constructors

SessionCallback

SessionCallback()

Public methods

onActiveChanged

Added in API level 21
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

Added in API level 21
abstract fun onBadgingChanged(sessionId: Int): Unit

Badging details for an existing session has changed. For example, the app icon or label has been updated.

onCreated

Added in API level 21
abstract fun onCreated(sessionId: Int): Unit

New session has been created. Details about the session can be obtained from PackageInstaller.getSessionInfo(int).

onFinished

Added in API level 21
abstract fun onFinished(
    sessionId: Int,
    success: Boolean
): Unit

Session has completely finished, either with success or failure.

onProgressChanged

Added in API level 21
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.