Example usage for android.app.usage UsageStatsManager INTERVAL_YEARLY

List of usage examples for android.app.usage UsageStatsManager INTERVAL_YEARLY

Introduction

In this page you can find the example usage for android.app.usage UsageStatsManager INTERVAL_YEARLY.

Prototype

int INTERVAL_YEARLY

To view the source code for android.app.usage UsageStatsManager INTERVAL_YEARLY.

Click Source Link

Document

An interval type that spans a year.

Usage

From source file:com.farmerbb.taskbar.service.TaskbarService.java

@TargetApi(Build.VERSION_CODES.LOLLIPOP_MR1)
private List<AppEntry> getAppEntriesUsingUsageStats() {
    UsageStatsManager mUsageStatsManager = (UsageStatsManager) getSystemService(USAGE_STATS_SERVICE);
    List<UsageStats> usageStatsList = mUsageStatsManager.queryUsageStats(UsageStatsManager.INTERVAL_YEARLY,
            searchInterval, System.currentTimeMillis());
    List<AppEntry> entries = new ArrayList<>();

    for (UsageStats usageStats : usageStatsList) {
        AppEntry newEntry = new AppEntry(usageStats.getPackageName(), null, null, null, false);

        newEntry.setTotalTimeInForeground(usageStats.getTotalTimeInForeground());
        newEntry.setLastTimeUsed(usageStats.getLastTimeUsed());
        entries.add(newEntry);/* www .j av a 2  s  . c om*/
    }

    return entries;
}