App usage on API <= KitKat
posted 1 year ago
Hello All, I'm trying to find out the time for which an app is used in Android. In Android L, there's a nicely defined API called UsageStats to cater to my needs, but I'm finding it bit difficult to find this information on pre-L devices. I have a workaround for this, but I feel it's not a good approach to deal with this. Is there any way I can get the launch time of any app on device and the exit time too (when it goes away from foreground). Continuously polling ActivityManager can help, but if the launch and exit times can be found, it will be a better way of doing this.