Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use AndroidX lifecycle functions for App Fore/Backgrounded #667

Merged
merged 5 commits into from Jun 8, 2020

Conversation

prayansh
Copy link
Contributor

@prayansh prayansh commented Jun 5, 2020

Summary

Use androidx.lifecycle methods to fire Application Backgrounded | Application Foregrounded track calls when trackApplicationLifecycleEvents=true.
This feature allows us to load Segment Analytics "lazily" via an Activity rather than via the Application and still hook into all the lifecycle methods. This is due to the fact that AnalyticsActivityLifecycleCallbacks.onCreate gets called even if Analytics is loaded after the Application.onCreate.
The Lifecycle methods are also the recommended method of determining if an application is foregrounded/backgrounded.

Test Plan

  • Application Backgrounded | Application Foregrounded are sent when app starts. (Segment initialized via Application)
  • Application Backgrounded | Application Foregrounded are sent when app starts. (Segment initialized via Activity)
  • Application Installed are sent when app starts. (Segment initialized via Application)
  • Application Installed are sent when app starts. (Segment initialized via Activity)

@prayansh prayansh marked this pull request as ready for review June 5, 2020 17:29
@prayansh prayansh merged commit 37226c1 into master Jun 8, 2020
@prayansh
Copy link
Contributor Author

prayansh commented Jun 8, 2020

Closes #649

@prayansh prayansh deleted the pray/lifecycle-intercept branch February 19, 2021 21:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants