FileDocCategorySizeDatePackage
UsageStatsActivity.javaAPI DocAndroid 5.1 API4760Thu Mar 12 22:22:44 GMT 2015com.android.tests.usagestats

UsageStatsActivity

public class UsageStatsActivity extends android.app.ListActivity

Fields Summary
private static final long
USAGE_STATS_PERIOD
private android.app.usage.UsageStatsManager
mUsageStatsManager
private Adapter
mAdapter
private Comparator
mComparator
Constructors Summary
Methods Summary
protected voidonCreate(android.os.Bundle savedInstanceState)


    
        
        super.onCreate(savedInstanceState);
        mUsageStatsManager = (UsageStatsManager) getSystemService(Context.USAGE_STATS_SERVICE);
        mAdapter = new Adapter();
        setListAdapter(mAdapter);
    
public booleanonCreateOptionsMenu(android.view.Menu menu)

        MenuInflater inflater = getMenuInflater();
        inflater.inflate(R.menu.main, menu);
        return super.onCreateOptionsMenu(menu);
    
public booleanonOptionsItemSelected(android.view.MenuItem item)

        switch (item.getItemId()) {
            case R.id.log:
                startActivity(new Intent(this, UsageLogActivity.class));
                return true;

            default:
                return super.onOptionsItemSelected(item);
        }
    
protected voidonResume()

        super.onResume();
        updateAdapter();
    
private voidupdateAdapter()

        long now = System.currentTimeMillis();
        long beginTime = now - USAGE_STATS_PERIOD;
        Map<String, UsageStats> stats = mUsageStatsManager.queryAndAggregateUsageStats(
                beginTime, now);
        mAdapter.update(stats);