Connect Android SDK: lifecycle and session management

The page describes additional methods available in the Connect Android SDK.

Platform: Android 8-16
Languages: Kotlin and Java
Declared in: Connect


App

Connect.setApplication

Sets the application context.

Connect.setApplication(app: Application)

Parameters:

  • app (required) — The host Application instance.

Connect.getApplication

Returns the application context.

Connect.getApplication(): Application?

Connect.isApplicationInBackground

Returns true if the application is in the background.

Connect.isApplicationInBackground(): Boolean

Connect.hasBeenPostedInBackground

Returns true if the library posted messages while the application was in the background.

Connect.hasBeenPostedInBackground(): Boolean

Activity and fragment lifecycle

Connect.onResume

Notifies the library that an activity has resumed. Call from your activity's onResume().

Connect.onResume(
    activity: Activity?,
    logicalPageName: String?
): Boolean

Parameters:

  • activity (required) — The activity that resumed.
  • logicalPageName (required) — The logical name of the screen.

Connect.onPause

Notifies the library that an activity has paused. Call from your activity's onPause().

Connect.onPause(
    activity: Activity?,
    logicalPageName: String?
): Boolean

Parameters:

  • activity (required) — The activity that paused.
  • logicalPageName (required) — The logical name of the screen.

Connect.onResumeFragment

Notifies the library that a fragment has resumed.

Connect.onResumeFragment(
    activity: Activity?,
    logicalPageName: String?,
    fragment: Any?
): Boolean

Parameters:

  • activity (required) — The host activity.
  • logicalPageName (required) — The logical name of the fragment.
  • fragment (required) — The fragment that resumed.

Connect.onPauseFragment

Notifies the library that a fragment has paused.

Connect.onPauseFragment(
    activity: Activity?,
    logicalPageName: String?,
    fragment: Any?
): Boolean

Parameters:

  • activity (required) — The host activity.
  • logicalPageName (required) — The logical name of the fragment.
  • fragment (required) — The fragment that paused.

Connect.onPauseNoActivityInForeground

Notifies the library that no activity is currently in the foreground.

Connect.onPauseNoActivityInForeground(): Boolean

Connect.pauseTealeaf

Temporarily pauses data capture.

Connect.pauseTealeaf(): Boolean

Connect.resumeTealeaf

Resumes data capture after Connect.pauseTealeaf().

Connect.resumeTealeaf(): Boolean

Connect.pauseTealeafIsUsingPause

Pauses data capture and records that the library is in the paused state.

Connect.pauseTealeafIsUsingPause(usingPause: Boolean?): Boolean

Parameters:

  • usingPause (required) — Whether the library should record that it is in the paused state.

Connect.isUsingPause

Returns true if the library is currently in the paused state.

Connect.isUsingPause(): Boolean

Connect.resumeConnect

Resumes data capture after a pause.

Connect.resumeConnect(
    activity: Activity?,
    logicalPageName: String
): Boolean

Connect.resumeConnect(
    activity: Activity?,
    logicalPageName: String,
    postSession: Boolean
): Boolean

Parameters:

  • activity (required) — The activity that resumed.
  • logicalPageName (required) — The logical name of the screen.
  • postSession (optional) — Whether to post a session message on resume.

Screen views

Connect.getCurrentLogicalPageName

Returns the logical name of the current screen.

Connect.getCurrentLogicalPageName(): String

Connect.setCurrentLogicalPageName

Sets the logical name of the current screen.

Connect.setCurrentLogicalPageName(name: String)

Parameters:

  • name (required) — The logical name to assign to the current screen.

Connect.getCurrentScreenView

Returns the current Screenview object.

Connect.getCurrentScreenView(): Screenview?

Gestures

Connect.dispatchTouchEvent

Dispatches a touch event to the library for gesture tracking. Call from your base activity's dispatchTouchEvent().

Connect.dispatchTouchEvent(
    activity: Activity?,
    motionEvent: MotionEvent?
): Boolean

Parameters:

  • activity (required) — The activity that received the touch event.
  • motionEvent (required) — The MotionEvent to dispatch.

Connect.getDetector

Returns the current gesture detector.

Connect.getDetector(): GestureDetector

Connect.setDetector

Sets the gesture detector.

Connect.setDetector(detector: GestureDetector?)

Parameters:

  • detector (required) — The GestureDetector to use. Pass null to clear.

Messages

Connect.setAdditionalHeaders

Sets additional HTTP headers to include on outgoing messages.

Connect.setAdditionalHeaders(headers: HashMap<String?, String?>?)

Parameters:

  • headers (required) — Key-value pairs of additional headers. Pass null to clear.

Connect.getAdditionalHeaders

Returns the additional HTTP headers configured for outgoing messages.

Connect.getAdditionalHeaders(): HashMap<String, String>

Connect.setAdditionalCookie

Sets an additional cookie to include on outgoing messages.

Connect.setAdditionalCookie(cookie: String?)

Parameters:

  • cookie (required) — The cookie value to include. Pass null to clear.

Connect.getAdditionalCookie

Returns the additional cookie configured for outgoing messages.

Connect.getAdditionalCookie(): String

Connect.getMessageVersion

Returns the message version.

Connect.getMessageVersion(): String

Capture

Connect.isCaptureScreenContentsEnabled

Returns true if screen-contents capture is enabled.

Connect.isCaptureScreenContentsEnabled(): Boolean

Connect.updateCaptureScreenContentsEnabled

Enables or disables screen-contents capture.

Connect.updateCaptureScreenContentsEnabled(enabled: Boolean): Boolean

Parameters:

  • enabled (required) — true to enable, false to disable.

Connect.getDefaultLogLevel

Returns the default log level used by logging methods when no level is specified.

Connect.getDefaultLogLevel(): Int

Queues

Connect.flushQueues

Flushes all pending data in the library's queues.

Connect.flushQueues(): Boolean

Connect.displayUpdate

Forces the library to post pending screen updates.

Connect.displayUpdate(): Boolean

Diagnostics

Connect.getHttpXTealeafProperty

Returns the value of the X-Tealeaf HTTP header property for the current session.

Connect.getHttpXTealeafProperty(): String

Connect.getEOCoreDeviceId

Returns the EOCore device ID.

Connect.getEOCoreDeviceId(): String

Connect.setEOCoreDeviceId

Sets the EOCore device ID.

Connect.setEOCoreDeviceId(deviceId: String): Boolean

Parameters:

  • deviceId (required) — The device ID to assign.

Connect.getEOCoreCurrentSessionId

Returns the EOCore current session ID.

Connect.getEOCoreCurrentSessionId(): String?

Connect.getPixelDensity

Returns the pixel density used when capturing screen layouts.

Connect.getPixelDensity(): Float