Language

UsageStatsManager.QueryAppUsageDuration(AppUsageDurationQuery) Method

Definition

Gets application usage stats for the given time range, aggregated by the specified interval.

[Android.Runtime.Register("queryAppUsageDuration", "(Landroid/app/usage/AppUsageDurationQuery;)Ljava/util/List;", "", ApiSince=37)]
[Android.Runtime.RequiresPermission("android.permission.QUERY_APP_USAGE")]
public System.Collections.Generic.IList<Android.App.Usage.AppUsageDuration> QueryAppUsageDuration(Android.App.Usage.AppUsageDurationQuery query);
[<Android.Runtime.Register("queryAppUsageDuration", "(Landroid/app/usage/AppUsageDurationQuery;)Ljava/util/List;", "", ApiSince=37)>]
[<Android.Runtime.RequiresPermission("android.permission.QUERY_APP_USAGE")>]
member this.QueryAppUsageDuration : Android.App.Usage.AppUsageDurationQuery -> System.Collections.Generic.IList<Android.App.Usage.AppUsageDuration>

Parameters

query
AppUsageDurationQuery

the AppUsageDurationQuery used to specify the query parameters. This value cannot be null.

Returns

a list of AppUsageDuration for each app used for the given time interval. This value cannot be null.

Attributes

Remarks

Gets application usage stats for the given time range, aggregated by the specified interval.

The usage statistics are pre-aggregated internally into calendar-aligned boundaries (e.g., for INTERVAL_DAILY, a day is defined as midnight to midnight local time). The returned list will only contain apps that have been used in this time range.

The returned list will contain one or more AppUsageDuration objects for each package, with usage data aggregated within each interval bucket that falls within the time range between AppUsageDurationQuery.getStartTimeMillis() and AppUsageDurationQuery.getEndTimeMillis(), which may include the expanded interval periods as described above.

Data can only be queried for the past 30 days. Queries for longer time ranges will return an empty list. Requires Manifest.permission.QUERY_APP_USAGE

Android reference for android.app.usage.UsageStatsManager.queryAppUsageDuration.

Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.

Applies to