Example usage for android.app.usage UsageStatsManager INTERVAL_BEST

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

Introduction

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

Prototype

int INTERVAL_BEST

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

Click Source Link

Document

An interval type that will use the best fit interval for the given time range.

Usage

From source file:research.sg.edu.edapp.kb.KbSoftKeyboard.java

public String getTopPackage() {

    RecentUseComparator mRecentComp = new RecentUseComparator();

    long ts = System.currentTimeMillis();
    UsageStatsManager mUsageStatsManager = (UsageStatsManager) getSystemService(Context.USAGE_STATS_SERVICE);
    List<UsageStats> usageStats = mUsageStatsManager.queryUsageStats(UsageStatsManager.INTERVAL_BEST,
            ts - 1000 * 10, ts);//from www .j a  va 2  s  .  com
    if (usageStats == null || usageStats.size() == 0) {
        //return NONE_PKG;
        return old_pkg;
    }
    Collections.sort(usageStats, mRecentComp);
    old_pkg = usageStats.get(0).getPackageName();
    return usageStats.get(0).getPackageName();
}