How do i get screen time of other applications in android?

本秂侑毒 提交于 2021-02-10 12:47:41

问题


I want to reach screen time of every application that's working on android system. For example, there are 3 hours of facebook working time but 1.2 hours of screen time. How can i get it?


回答1:


android.app.usage

UsageStats

public final class UsageStats 
extends Object implements Parcelable

java.lang.Object
   ↳    android.app.usage.UsageStats

What you need I think is

getFirstTimeStamp

Get the beginning of the time range this UsageStats represents, measured in milliseconds since the epoch. and getLastTimeStamp

Get the end of the time range this UsageStats represents, measured in milliseconds since the epoch.

Documentation



来源:https://stackoverflow.com/questions/50190912/how-do-i-get-screen-time-of-other-applications-in-android

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