usagestatsmanager

How to count app usage time while app is on foreground?

余生长醉 提交于 2020-05-21 06:45:33
问题 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

How to count app usage time while app is on foreground?

大兔子大兔子 提交于 2020-05-21 06:42:54
问题 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

How to count app usage time while app is on foreground?

蓝咒 提交于 2020-05-21 06:42:04
问题 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

How can I get my app screen time on a hourly basis? [duplicate]

不问归期 提交于 2020-05-20 10:39:27
问题 This question already has an answer here : How to count app usage time while app is on foreground? (1 answer) Closed 4 days ago . Android's UsageStatsManager returning data for minimum one day, but I want to get accurate data from 12 am to the current time. I tried several types but nothing works properly. The "Action Dash" and "Digital Wellbeing" is getting data accurately. 回答1: Use queryEvents method of UsageStatsManager class. I've recently built an app for tracking daily app usage.

How can I get my app screen time on a hourly basis? [duplicate]

泄露秘密 提交于 2020-05-20 10:38:07
问题 This question already has an answer here : How to count app usage time while app is on foreground? (1 answer) Closed 4 days ago . Android's UsageStatsManager returning data for minimum one day, but I want to get accurate data from 12 am to the current time. I tried several types but nothing works properly. The "Action Dash" and "Digital Wellbeing" is getting data accurately. 回答1: Use queryEvents method of UsageStatsManager class. I've recently built an app for tracking daily app usage.

How to get usage stats for “current day” using usageStatsManager in android (kotlin)

。_饼干妹妹 提交于 2020-01-30 05:15:52
问题 Objective: Need to get the usage stats for today (total time for which the device was used today) ie. 12.00 am to current time. Problem: 1.I get today's time + some other non explainable time 2.Non explainable time stamps(start and end of the usage stats as retrieved by the getTimestamp methods) The time bucket is not relevant. I give the start time as 12.00 am and the end time as current time, but I get completely irrelevant ".firstTimeStamp" and ".lastTimeStamp" (which supposedly return the

Android UsageStatsManager: Get a list of currently running apps on phone

老子叫甜甜 提交于 2020-01-13 16:54:39
问题 I am trying to get a list of currently running apps on my phone. Here is the code I am using: if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.LOLLIPOP) { UsageStatsManager usm = (UsageStatsManager)this.getSystemService(Context.USAGE_STATS_SERVICE); long time = System.currentTimeMillis(); List<UsageStats> appList = usm.queryUsageStats(UsageStatsManager.INTERVAL_DAILY, time - 10000*10000, time); if (appList != null && appList.size() == 0) { Log.d("Executed app", "########

Is android.permission.PACKAGE_USAGE_STATS Only for System Apps?

强颜欢笑 提交于 2019-12-24 11:35:02
问题 I am accessing user stats in the following ways: UsageStatsManager userStatsMgr = (UsageStatsManager)getSystemService("usagestats"); List<UsageStats> userStats = mUsageStatsManager.queryUsageStats(UsageStatsManager.INTERVAL_BEST, timeStamp - 1000*200, timeStamp) Seems to work for: android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.LOLLIPOP But I am not sure whether it will continue to work on newer SDK? I see some warning while using this permission, but those were not

Count how many times every app is used in one day using UsageEvents, UsageEvents.Event and MOVE_TO_FOREGROUND

懵懂的女人 提交于 2019-12-24 09:31:18
问题 With UsageStatsManager and UsageStats I'm able to obtain the daily usage (in houres, minuts and seconds) of every app on my smartphone. Now I want to know if there is a way to obtain the daily frequency of use (in numbers of times, i.e. 1 times, 2 times, etc) of every app on my smartphone. Reading the documentation I deduced that this could be achieved using UsageEvents, UsageEvents.Event and MOVE_TO_FOREGROUND. So I wrote the following code: // Get the app statistics since one day ago from

Android get UsageStatsManager in API level 21

孤人 提交于 2019-12-22 11:09:12
问题 I need to get info about recent apps usage. Before API 21 it was used getRunningTasks or getRecentTasks to get this info. These methods were deprecated in API 21 according docs. There is UsageStatsManager class now, introduced in API level 21. But! Context.getSystemService(UsageStatsService) was added only in API level 22! The question is - how to get needed data in API 21 ?? According dashboards, there is 13% of users at this API level, I don't wanna lose them. 回答1: Well Context