How to get application usage statistics on android?
What I want is to access the time (in milliseconds) 开发者_JS百科that each application is used.
Thanks
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.
You could use TraceView. Did you mean by programming?
By Programming, You can check out how SpareParts does it.
@João Lopes,Chris Stratton
Google Provide the sample code for AppUsageStatistics Sample
Here full of statistics base on daily weekly monthly usages.
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
you can try to use FireBase Analytics.
精彩评论