app_usage 2.0.0
app_usage: ^2.0.0 copied to clipboard

App usage plugin for Android only

app_usage #

pub package

Application usage stats for Android only. Note that the stats are only precise down to a daily basis. This is a limitation from Google's implementation, unfortunately.

Install #

Add app_usage as a dependency in pubspec.yaml. For help on adding as a dependency, view the documentation.

Android #

NB: Requires API level 21 as a minimum!

I.e. you need to set the min SDK version inside the android/app/build.gradle:

minSdkVersion 21

You need to add the following package to the manifest namespace in AndroidManifest.xml:


as well as the following permissions to the manifest:

        tools:ignore="ProtectedPermissions" />

Below is an example of how the start of your manifest should look in the end

<manifest xmlns:android=""


Usage #

  void getUsageStats() async {
    try {
      DateTime startDate = DateTime(2018, 01, 01);
      DateTime endDate = new;
      List<AppUsageInfo> infos = await AppUsage.getAppUsage(startDate, endDate);
      setState(() {
        _infos = infos;
    } on AppUsageException catch (exception) {

Each AppUsageInfo object has the following public fields:

  /// The name of the application
  String get appName;

  /// The name of the application package
  String get packageName;

  /// The amount of time the application has been used
  /// in the specified interval
  Duration get usage;

  /// The start of the interval
  DateTime get startDate;

  /// The end of the interval
  DateTime get endDate;

Example screenshot #

The first screen will ask for permission to view usage stats. Tap on your application. Screenshot