Okay the question is pretty simple. The hard part has been that my app features gallery and camera functionality, that means that OnStop and OnResume trigger when technically the user is using the app, but that isn't that much of an issue (I can ignore the time they spend using the those features). The issue is when do I log the event? I tried logging it onDestroy but that never seems to be happening. Single activity approach, so as long the activity is up and running that how long the user was using the app.
Any suggestion is welcomed
I am currently using this (never getting logged)
override fun onResume() {
startTime = System.currentTimeMillis()
super.onResume()
}
override fun onPause() {
timeSpent += System.currentTimeMillis().minus(startTime)
super.onPause()
}
override fun onDestroy() {
firebaseEventManager.logTimeSpentInApp(timeSpent)
Timber.d("On Destroy")
super.onDestroy()
}