List of usage examples for android.app.usage UsageStatsManager INTERVAL_YEARLY
int INTERVAL_YEARLY
To view the source code for android.app.usage UsageStatsManager INTERVAL_YEARLY.
Click Source Link
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; }