How to Track App Usage in Android? How to detect when an activity is launched?

后端 未结 2 2044
忘掉有多难
忘掉有多难 2020-12-02 14:35

I need to track app usage in Android like how AppUsage does it (i.e. track number of app launches, and time spent using each). What I plan on doing is record the start time

2条回答
  •  一个人的身影
    2020-12-02 15:09

    We can now access app usage history on an Android device with the new android.app.usage API released as part of Android 5.0 APIs.The system collects the usage data on a per-app basis, aggregating the data over daily, weekly, monthly, and yearly intervals

    For each app, the system records the following data:

    • The last time the app was used
    • The total length of time the app was in the foreground for that time interval (by day, week, month, or year)
    • Timestamp capturing when a component (identified by a package and activity name) moved to the foreground or background during a day

    • Timestamp capturing when a device configuration changed (such as when the device orientation changed because of rotation)

    Refr : http://developer.android.com/reference/android/app/usage/package-summary.html

提交回复
热议问题