Added in API level 21

UsageStats


class UsageStats : Parcelable
kotlin.Any
   ↳ android.app.usage.UsageStats

Contains usage statistics for an app package for a specific time range.

Summary

Inherited constants
Public constructors

Public methods
Unit
add(right: UsageStats!)

Add the statistics from the right UsageStats to the left.

Int

Long

Get the beginning of the time range this android.app.usage.UsageStats represents, measured in milliseconds since the epoch.

Long

Get the last time this package's foreground service was used, measured in milliseconds since the epoch.

Long

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

Long

Get the last time this package's activity was used, measured in milliseconds since the epoch.

Long

Get the last time this package's activity is visible in the UI, measured in milliseconds since the epoch.

String!

Long

Get the total time this package's foreground services are started, measured in milliseconds.

Long

Get the total time this package spent in the foreground, measured in milliseconds.

Long

Get the total time this package's activity is visible in the UI, measured in milliseconds.

Unit
writeToParcel(dest: Parcel, flags: Int)

Properties
static Parcelable.Creator<UsageStats!>

Public constructors

UsageStats

Added in API level 21
UsageStats(stats: UsageStats!)

Public methods

add

Added in API level 21
fun add(right: UsageStats!): Unit

Add the statistics from the right UsageStats to the left. The package name for both UsageStats objects must be the same.

Parameters
right UsageStats!: The UsageStats object to merge into this one.
Exceptions
java.lang.IllegalArgumentException if the package names of the two UsageStats objects are different.

describeContents

Added in API level 21
fun describeContents(): Int
Return
Int a bitmask indicating the set of special object types marshaled by this Parcelable object instance. Value is either 0 or android.os.Parcelable#CONTENTS_FILE_DESCRIPTOR

getFirstTimeStamp

Added in API level 21
fun getFirstTimeStamp(): Long

Get the beginning of the time range this android.app.usage.UsageStats represents, measured in milliseconds since the epoch.

See System.currentTimeMillis().

getLastTimeForegroundServiceUsed

Added in API level 29
fun getLastTimeForegroundServiceUsed(): Long

Get the last time this package's foreground service was used, measured in milliseconds since the epoch.

See System.currentTimeMillis().

getLastTimeStamp

Added in API level 21
fun getLastTimeStamp(): Long

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

See System.currentTimeMillis().

getLastTimeUsed

Added in API level 21
fun getLastTimeUsed(): Long

Get the last time this package's activity was used, measured in milliseconds since the epoch.

See System.currentTimeMillis().

getLastTimeVisible

Added in API level 29
fun getLastTimeVisible(): Long

Get the last time this package's activity is visible in the UI, measured in milliseconds since the epoch.

getPackageName

Added in API level 21
fun getPackageName(): String!

getTotalTimeForegroundServiceUsed

Added in API level 29
fun getTotalTimeForegroundServiceUsed(): Long

Get the total time this package's foreground services are started, measured in milliseconds.

getTotalTimeInForeground

Added in API level 21
fun getTotalTimeInForeground(): Long

Get the total time this package spent in the foreground, measured in milliseconds. When in the foreground, the user is actively interacting with the app.

getTotalTimeVisible

Added in API level 29
fun getTotalTimeVisible(): Long

Get the total time this package's activity is visible in the UI, measured in milliseconds. Note: An app may be visible but not considered foreground. Apps in the foreground must be visible, so visible time includes time in the foreground.

writeToParcel

Added in API level 21
fun writeToParcel(
    dest: Parcel,
    flags: Int
): Unit
Parameters
dest Parcel: The Parcel in which the object should be written. This value cannot be null.
flags Int: Additional flags about how the object should be written. May be 0 or PARCELABLE_WRITE_RETURN_VALUE. Value is either 0 or a combination of android.os.Parcelable#PARCELABLE_WRITE_RETURN_VALUE, and android.os.Parcelable.PARCELABLE_ELIDE_DUPLICATES

Properties

CREATOR

Added in API level 21
static val CREATOR: Parcelable.Creator<UsageStats!>