usage_stats

Creator: coderz1093

Last updated:

0 purchases

usage_stats Image
usage_stats Images

Languages

Categories

Add to Cart

Description:

usage stats

usage_stats #




Query Android Usage Statistics (Configuration, Events, App Usage)
Install #
Add usage_stats as a dependency in pubspec.yaml.
Android #
Requires API level 22 as a minimum!
Add the following permission to the manifest namespace in AndroidManifest.xml:
<uses-permission
android:name="android.permission.PACKAGE_USAGE_STATS"
tools:ignore="ProtectedPermissions" />
copied to clipboard
Usage #
import 'package:usage_stats/usage_stats.dart';

getUsage() async {

DateTime endDate = new DateTime.now();
DateTime startDate = DateTime(endDate.year, endDate.month, endDate.day, 0, 0, 0);

// grant usage permission - opens Usage Settings
UsageStats.grantUsagePermission();

// check if permission is granted
bool isPermission = UsageStats.checkUsagePermission();

// query events
List<EventUsageInfo> events = await UsageStats.queryEvents(startDate, endDate);

// query usage stats
List<UsageInfo> usageStats = await UsageStats.queryUsageStats(startDate, endDate);

// query eventStats API Level 28
List<EventInfo> eventStats = await UsageStats.queryEventStats(startDate, endDate);

// query configurations
List<ConfigurationInfo> configurations = await UsageStats.queryConfiguration(startDate, endDate);

// query aggregated usage statistics
Map<String, UsageInfo> queryAndAggregateUsageStats = await UsageStats.queryAndAggregateUsageStats(startDate, endDate);

// query network usage statistics
List<NetworkInfo> networkInfos = await UsageStats.queryNetworkUsageStats(startDate, endDate, networkType: NetworkType.all);

}
copied to clipboard
To DO #

Add option to pass Interval Type in queryUsageStats, queryEventStats method
Add Unit Tests

License

For personal and professional use. You cannot resell or redistribute these repositories in their original state.

Customer Reviews

There are no reviews.