Pause and resume screen capture in a native Android app

By default, the Connect library captures all screens in your app. If you need to exclude specific screens at runtime — for example, screens with sensitive information — you can pause and resume capture using activity lifecycle methods.

Languages: Kotlin and Java

Availability: Pro, Premium, and Ultimate

Choose your approach

Two ways to exclude a screen from capture:

  • Declaratively, in ConnectLayoutConfig.json. Set ScreenChange=false for the screen and the SDK skips it automatically. This is the cleaner approach when you know the screen at compile time — there is no risk of forgetting to resume. See Configure data capture settings in a native Android app.
  • Programmatically, with the pause/resume API. Use this when the decision to skip a screen depends on runtime state — for example, a single activity that displays sensitive content only in certain modes.

This guide covers the programmatic approach.

How pause and resume work

Connect.pauseTealeaf() and Connect.resumeConnect() flip a global capture flag. Pausing on one activity stops capture across the entire SDK until you explicitly resume — including any other activities the user opens in between. To avoid leaving the SDK paused, always pair every pause with a resume in the appropriate lifecycle method.

Pause capture on a sensitive screen

In the activity you want to exclude, call Connect.pauseTealeaf() in onStart(). onStart() is invoked every time the activity becomes visible, including when the user returns to it from the background, so capture is stopped before any layout or gesture is recorded.

override fun onStart() {
    super.onStart()
    Connect.pauseTealeaf()
}

Resume capture when the user leaves

In the same activity, call Connect.resumeConnect() in onStop(). onStop() fires when the activity is no longer visible — whether the user navigated to another screen or pressed Home. Resuming here ensures capture is restored as soon as the sensitive screen leaves the foreground.

override fun onStop() {
    Connect.resumeConnect(this, "NextScreenName")
    super.onStop()
}

resumeConnect() takes two arguments:

  • activity — the current activity reference, used by the SDK to capture the new screen's layout.
  • logicalPageName — the name of the screen Connect should associate with the captured session from this point forward.

Alternative: resume without logging a screen view

If you want to re-enable capture without logging a new screen view — for example, returning to a screen the SDK has already captured before — use Connect.resumeTealeaf() instead. It takes no arguments and only re-enables the capture flag.

Connect.resumeTealeaf()