How to count app usage time while app is on foreground?
问题 I'm working on an android app for tracking daily app usage. The idea is that a user can set daily time limit for any app and a notification will appear within at most 2 minutes after the limit is exceeded. (The reason for delay: I've created an alarm system using AlarmManager class that will go off every minute to run a JobIntentService which will check whether limit for any app is exceeded) I've used queryEvents method of UsageStatsManager class to count app usage time. Here's my code for