title: How to Track App Usage in Android? How to detect when an activity is launched?
body: <p>I need to track app usage in Android like how AppUsage does it (i.e. track number of app launches, and time spent using each). What I plan on doing is record the start time when an app is launched, and then get the end time when an app is paused or stopped. In LogCat, I'm able to see logs of Activity starting. I've looked at the available system broadcasts, I'm not sure if there is anything that broadcasts whenever an activity is started. . Basically, how do I detect when an activity is launched?</p>
  
  <p>Edit:
  Moreover, Android also has a usage statistics system available internally which can be found in the Spare Parts app or when <code>*#*#4636#*#*</code> is dialed (Testing -> Usage statistics)</p>