adobe / adobe/aepsdk-core-android
Investigate using/recommending ProcessLifecycleOwner for tracking lifecycle calls
- Dominant language
- Kotlin
- Stars
- 17
- Forks
- 30
- Avg merge
- 8h 37m
- Merged PRs (30d)
- 5
Description
- The application.launch metric is collected as part of the [lifecycle application foreground](https://developer.adobe.com/client-sdks/home/base/mobile-core/lifecycle/event-reference/#lifecycle-application-foreground) (triggered by MobileCore.lifecycleStart()) which is a notification that the application is in the foreground. This notification is recommended to be sent when each activity of the application resumes.
- The application.close metric is collected as part of and [lifecycle application background](https://developer.adobe.com/client-sdks/home/base/mobile-core/lifecycle/event-reference/#lifecycle-application-background) (triggered by MobileCore.lifecyclePause()) event which is a notification that the application is in the background. This notification recommended to be sent when each activity of the application pauses.
Since these lifecycle metrics are collected for each activity, transitioning from one activity to another will result in the following events in order:
1. Lifecycle application foreground (first activity starts)
2. Lifecycle application background (first activity pauses)
3. Lifecycle application foreground (second activity starts).
However, if the time between the first activity pausing and the second activity resuming is less than 500 milliseconds, the lifecycle session is said to be continuing and events 2 and 3 are not sent. If the time between first activity pausing and the second activity resuming is more that 500 milliseconds, the events 2 and 3 are sent marking them as separate sessions.
This approach does not allow Edge customers to rely on `application.launches` for reliably tracking launches.
Investigate using ProcessLifecycleOwner and change their app to do the following instead of lifecycle calls per activity.
```
class App : Application(), DefaultLifecycleObserver {
override fun onCreate() {
super.onCreate()
ProcessLifecycleOwner.get().lifecycle.addObserver(this)
}
override fun onResume(owner: LifecycleOwner) {
super.onResume(owner)
MobileCore.lifecycleStart(vinMapping)
}
override fun onPause(owner: LifecycleOwner) {
super.onPause(owner)
MobileCore.lifecyclePause()
}
}
```
}
Contributor guide
Assessment
This issue has not been assessed yet.