keeping track of time a user is actively using an android app
<p>I am trying to find the best way to keep track of how much time a user spent on an android application (to report it to a server). I am only interested in tracking time where the user seems to use the app, so if it's in the background i shouldn't count that time for example.
I did some research and the only suggestion I found so far is using the onResume() and onPause() methods of activities to keep track of elapsed time between those 2 calls; I would probably need to do this in each activity of the application which doesn't seem to be a very elegant solution.
Is there another way, or better way to keep track of this time?</p>

<p>thanks in advance for the help.</p>
