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

不问归期 提交于 2020-05-20 10:39:27

问题


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. Firstly, I tried using queryUsageStats but it didn't work properly. I thought it was supposed to return usage time from 12 am to current time when INTERVAL_DAILY is passed to it, but instead it was returning something else. Maybe there is a bug or there is something wrong on my side related to time zone or something.

Anyway, then I tried queryEvents and it worked fine.

Here's my implementation (See both the question and the accepted answer).



来源:https://stackoverflow.com/questions/61615457/how-can-i-get-my-app-screen-time-on-a-hourly-basis

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!