register
Registers callback paired with lifecycle to be invoked later, and releases them when lifecycle is DESTROYED.
callback can be invoked when appropriate, given that an OutputCallbackToken corresponding to the one returned is provided on invoke.
It respects the lifecycle of other app components, such as activities, fragments, or services. This ensures callback is only invoked when lifecycle is in an active state, unless runWhileStopped is passed as true
, in which case it is invoked at any state until DESTROYED.
lifecycle is considered to be active when in the STARTED or RESUMED state.
Return
An OutputCallbackToken that identifies callback by it's origin, allowing it to be retrieved and invoked later.
Parameters
The Lifecycle which callback will be paired to.
The callback to be registered. Will be released when lifecycle be destroyed. May be invoked only when lifecycle is in an active state, or in whatever state until lifecycle be destroyed, according to runWhileStopped's value.