UsageStats class
Entry point for all usage-statistics queries. All methods are static.
Properties
- hashCode → int
-
The hash code for this object.
no setterinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited
Static Methods
-
checkUsagePermission(
) → Future< bool?> -
Whether the
PACKAGE_USAGE_STATSpermission has been granted to this app. -
getAppIcon(
String packageName) → Future< Uint8List?> -
Returns the PNG-encoded launcher icon for
packageName, or null if it cannot be resolved. -
getAppInfo(
String packageName) → Future< AppInfo?> -
Returns AppInfo metadata (label, system flag, version, install times)
for
packageName, or null if the package cannot be resolved. -
getAppStandbyBucket(
) → Future< int?> -
This app's current App Standby bucket
(e.g.
10active,20working set,30frequent,40rare). Requires no permission. -
grantUsagePermission(
) → Future< void> -
Opens the system "Usage access" settings screen so the user can grant
the
PACKAGE_USAGE_STATSpermission. Does nothing if already granted. -
isAppInactive(
String packageName) → Future< bool?> -
Whether
packageNameis currently considered inactive (idle). -
openUsageAccessSettings(
) → Future< void> - Opens the system "Usage access" settings screen unconditionally, even when the permission is already granted (handy for a "Manage access" button).
-
queryAndAggregateUsageStats(
DateTime startDate, DateTime endDate) → Future< Map< String, UsageInfo> > -
Returns per-app UsageInfo aggregated by package between
startDateandendDate, keyed by package name. -
queryConfiguration(
DateTime startDate, DateTime endDate) → Future< List< ConfigurationInfo> > -
Returns the device ConfigurationInfo entries between
startDateandendDate. -
queryEvents(
DateTime startDate, DateTime endDate) → Future< List< EventUsageInfo> > -
Returns the raw usage events between
startDateandendDate. -
queryEventsForSelf(
DateTime startDate, DateTime endDate) → Future< List< EventUsageInfo> > -
Returns this app's own usage events between
startDateandendDatewithout requiringPACKAGE_USAGE_STATS. -
queryEventStats(
DateTime startDate, DateTime endDate, {IntervalType? intervalType}) → Future< List< EventInfo> > -
Returns aggregated EventInfo statistics between
startDateandendDate. -
queryInstalledApps(
{bool includeSystem = true}) → Future< List< AppInfo> > - Returns AppInfo for every installed app the caller is allowed to see.
-
queryNetworkUsageStats(
DateTime startDate, DateTime endDate, {NetworkType networkType = NetworkType.all}) → Future< List< NetworkInfo> > -
Returns per-app NetworkInfo for all installed apps between
startDateandendDate, for the givennetworkType. -
queryNetworkUsageStatsByPackage(
DateTime startDate, DateTime endDate, {required String packageName, NetworkType networkType = NetworkType.all}) → Future< NetworkInfo> -
Returns NetworkInfo for a single
packageNamebetweenstartDateandendDate, for the givennetworkType. -
queryStorageStats(
String packageName) → Future< StorageInfo?> -
Returns app/data/cache StorageInfo for
packageName. -
queryUsageStats(
DateTime startDate, DateTime endDate, {IntervalType? intervalType}) → Future< List< UsageInfo> > -
Returns per-app UsageInfo statistics between
startDateandendDate.