Q:

How to track app usage time programmatically in android?

I want to know how much time user is using my app . So whenever he opens my app I want to know time and whenever he close app i want to know time. When user will close app i want to send usage time to server. How can i track usage time in android ?

A:

I would put data loges onResume and onPause methods. and on every onPause Append usage time to SharedPrefrences or some database and on requirements on create or  when internet is turned on i would send usage statistics. 
In this manner you can track every activities usage.
Not sure if some of the box methods exists.  

