Skip to content

Latest commit

 

History

History
96 lines (66 loc) · 4.26 KB

feature_navigation_and_lifecycle.md

File metadata and controls

96 lines (66 loc) · 4.26 KB

Feature - Navigation & Lifecycle

Measure SDK captures lifecycle and navigation events automatically, this includes the following:

  1. Application foregrounded/backgrounded
  2. Activity lifecycle
  3. Fragment lifecycle
  4. Screen Views

Application foregrounded/backgrounded

Measure automatically tracks when the application has come to foreground (is visible to the user) and when it has been put into background (is no longer visible to the user).

How it works

To detect when an Application goes to background, Measure registers tp Application.ActivityLifecycleCallbacks callback and checks when the last Activity on the stack receives an onStop event, effectively meaning the app is no longer visible to the user.

Similarly, to detect when an Application comes back to foreground, Measure relies on the same callbacks to check when the first Activity on the stack receives an onStart event, effectively meaning the app is now visible to the user.

Data collected

Checkout all the data collected for application lifecycle in the App Lifecycle Event section. section.

Activity lifecycle

Measure automatically tracks the following Activity lifecycle events:

  1. Created
  2. Resumed
  3. Paused
  4. Destroyed

How it works

Similar to Application lifecycle, Measure registers ActivityLifecycleCallbacks and tracks the lifecycle events of each Activity.

Data collected

Checkout all the data collected for Activity lifecycle in the Activity Lifecycle Event section.

Fragment lifecycle

Measure automatically tracks the following Fragment lifecycle events:

  1. Attached
  2. Resumed
  3. Paused
  4. Detached

How it works

Measure registers FragmentLifecycleCallbacks to track the lifecycle events of each Fragment. This is only done if androidx.Fragment dependency is added to the project.

Data collected

Checkout all the data collected for Fragment lifecycle in the Fragment Lifecycle Event section.

Note

Measure supports androidx.Fragment lifecycle events only, the legacy android.app.Fragment is not supported. The Fragment lifecycle events are only tracked if the androidx.Fragment dependency is added to the app. Measure does not introduce any dependency on androidx.Fragment automatically.

Screen Views

How it works

Measure instruments the AndroidX navigation library using ASM by automatically tracking all screen view events by registering NavController.OnDestinationChangedListener This is done using the Measure gradle plugin, read more details about it here.

Data collected

Checkout all the data collected for screen view in the Screen View Event section.

Note

Compose navigation events are only tracked if the project uses Compose and the Compose navigation library. Measure does not introduce any dependency on Compose navigation library automatically.