I am wanting to track the running time of a user's apps over time. The only way I can think to do this currently is run a background process that, each minute, grabs the list of running processes and adds them to the app's time count. Is there a more efficient way of doing this that doesn't require an operation in the background every minute?
Asked
Active
Viewed 66 times
0
-
Why you want to get time after every minute ? – Talha Q Feb 21 '14 at 21:02
-
This is so that I can get accuracy of app running time to 1 minute. – AggieDev Feb 21 '14 at 21:03
-
Sounds similar to what this person is doing: http://stackoverflow.com/questions/21766996/what-is-cpu-time-using-androids-ps-x/ – fadden Feb 22 '14 at 01:06
1 Answers
0
Instead of logging a certain interval i would log the time of application startup and application shutdown. To figure out when to log, look at the image at this link: http://developer.android.com/reference/android/app/Activity.html
As you can see you can just log the time in onCreate, and then again in onDestroy. Then i would save the difference in time between these and then save that to either a file or shared preferences or something similar.

Mattias F
- 602
- 6
- 11
-
I am trying to track the running time of other apps, not my own. I do not have access to other apps' onCreate()'s and onDestroy()'s. – AggieDev Feb 21 '14 at 23:12