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

question: What's the purpose of useLifecycleObserver option? #230

Closed
lwasyl opened this issue May 30, 2024 · 3 comments
Closed

question: What's the purpose of useLifecycleObserver option? #230

lwasyl opened this issue May 30, 2024 · 3 comments
Assignees

Comments

@lwasyl
Copy link

lwasyl commented May 30, 2024

Basically title, the default value is false, when would/should I set it to true? I want to track application lifecycle events so I'm setting trackApplicationLifecycleEvents to true but I don't know what's the significance of useLifecycleObserver. The documentation just says enables the use of LifecycleObserver to track Application lifecycle events but it doesn't explain what I should consider when enabling this flag

@wenxi-zeng
Copy link
Contributor

hi @lwasyl, trackApplicationLifecycleEvents = true tracks lifecycle events regardless the value of useLifecycleObserver, though in different ways. if useLifecycleObserver = false, lifecycle events are tracked via the old android lifecycle hooks ActivityLifecycleCallbacks. otherwise, lifecycle events are tracked via DefaultLifecycleObserver

for example, on activity created, if useLifecycleObserver = false, the sdk calls to the override method onCreated from DefaultLifecycleObserver explicitly to track lifecycle events. however, if useLifecycleObserver = true, onCreated is invoked by the lifecycle observer automatically. the end results are the same. choose the value that fits your use case.

@lwasyl
Copy link
Author

lwasyl commented May 30, 2024

Hi, thanks but that doesn't really answer my question - what would be my use case for using one or the other? As a library consumer I still don't know if I should change the default or not. If both options work the same, why have it configurable in the first place?

@wenxi-zeng
Copy link
Contributor

if you already use lifecycle observer in your app, you can set useLifecycleObserver = true, but you don't have to. this flag is designed for the apps that did not implement lifecycle observer.

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

No branches or pull requests

3 participants