Skip to main content
Version: 1.1.x

Screens - XML Views

Use Coryn.registerScreen() to register a Screen that participates in the androidx.lifecycle.Lifecycle. The SDK automatically activates and deactivates the Screen as the lifecycle changes, and clears the reference when the component is destroyed.

OfferDetailsActivity.kt
class OfferDetailsActivity : AppCompatActivity() {
...

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
Coryn.registerScreen(
name = "OfferDetails",
activity = this,
arguments = bundleOf("title" to "Gothic II: Night of the Raven")
)
}

...
}
tip

Pass arguments to distinguish between different instances of the same Screen. For example, a product detail screen shown for different products will appear as separate, labelled entries in the session timeline.

Fragments and custom lifecycles​

For a full-screen Fragment, call Coryn.registerScreen(name, fragment = this, arguments = ...) in onViewCreated(). Registration follows the current view lifecycle, not the Fragment instance lifetime; it is skipped if the Fragment has no current view.

A custom-lifecycle overload requires both savedStateRegistryOwner and lifecycle. Use the Activity or Fragment overload when possible.

Screen arguments support String, Number, and Boolean values. They are recorded data and are not redacted by visual privacy masks; avoid sensitive values.

Manual lifecycle management​

In the rare case where your component does not have a Lifecycle, use Coryn.registerManualScopeScreen() instead. This returns a CorynManualScopeScreenId that you must later pass to Coryn.unregisterManualScopeScreen() when the Screen is no longer active.

val screenId = Coryn.registerManualScopeScreen(
name = "CustomOverlay",
arguments = null
)

// Later, when the overlay is dismissed:
Coryn.unregisterManualScopeScreen(screenId)
warning

Prefer Coryn.registerScreen() with a Lifecycle wherever possible. Only use the manual scope variant when no Lifecycle is available.

See screen naming guidelines for consistent names and arguments.