### Get UsageStatsManager Instance Source: https://github.com/googlesamples/android-appusagestatistics/blob/master/README.md Obtain an instance of UsageStatsManager to access app usage statistics. This is a prerequisite for querying usage data. ```java mUsageStatsManager = (UsageStatsManager) getActivity() .getSystemService(Context.USAGE_STATS_SERVICE); ``` -------------------------------- ### Query App Usage Statistics Source: https://github.com/googlesamples/android-appusagestatistics/blob/master/README.md Retrieve app usage statistics for a specified time interval. The query can be filtered by daily, weekly, monthly, or yearly intervals and a custom date range. ```java Calendar cal = Calendar.getInstance(); cal.add(Calendar.YEAR, -1); List queryUsageStats = mUsageStatsManager .queryUsageStats(UsageStatsManager.INTERVAL_DAILY, cal.getTimeInMillis(), System.currentTimeMillis()); ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.