-
Notifications
You must be signed in to change notification settings - Fork 3
Android Caveats
##Session Tracking##
App Lifecycle is not very well defined nor controlled in the Android ecosystem. As a result, knowing when an App officially "closes" can be close to impossible for certain implementations.
There isn't one surefire solution to it, but we have a few options for you based on the way your might app is used;
If your app doesn't push out to other activities or applications, then putting a startSession
call in onResume
and an endSession
call to onPause
is the easiest way to go. Luckily most Phonegap apps should fall into this category.
If for any reason you need to start a new activity but want to be considered still "in the app," then the solution starts becoming more difficult. If your app has multiple ways of being opened via Intents, then knowing app state independent of Activities is required. A slightly better solution would be to override the Application class and put the startSession
and endSession
calls in its onResume
and onPause
. This solution still doesn't cover all cases, but it covers more of them.