Reputation: 1022
What I want is to access the time (in milliseconds) that each application is used.
Thanks
Upvotes: 5
Views: 3609
Reputation: 666
Firebase Analytics has a cool feature where it tracks the average time on each screen and the percentage of which screen is used most often.
Is this is good enough for you, I would suggest adding Firebase to your app, as it has a free plan, and it will automatically track your users' time. You can start here
Hope this helps
Upvotes: 0
Reputation: 6821
@João Lopes,Chris Stratton
Google Provide the sample code for AppUsageStatistics Sample
Here full of statistics base on daily weekly monthly usages.
Upvotes: 0
Reputation: 40407
Dig up the source to "Spare Parts" and see how they do it
(also copy it off the emulator, install it on your phone and make sure it works)
Note: while this remains accurate for the circa-2010 versions of Android about which it was written, restrictions added years later in 4.4 and 5.0 would substantially frustrate achieving this in more recent versions.
Upvotes: 1
Reputation: 33575
You could use TraceView. Did you mean by programming?
By Programming, You can check out how SpareParts does it.
Upvotes: 0