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

后端 未结 2 453
孤独总比滥情好
孤独总比滥情好 2021-01-18 20:39

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 ti

2条回答
  •  天命终不由人
    2021-01-18 21:16

    I actually experience a similar problem:

    According to my understanding of the documentation firstTimeStamp and lastTimeStamp should give the "beginning (end) of the time range this UsageStats represents".

    They differ however from what I give as an argument in queryAndAggregateUsageStats as beginTime and endTime.

    Also the result for the totalTimeInForegroundseems rather give back a result for the timespan given by firstTimeStamp / lastTimeStamp than for the requested one.

    I filled a bug with google for this, please have a look at https://issuetracker.google.com/issues/118564471.

提交回复
热议问题