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

UsageLogActivity

public class UsageLogActivity extends android.app.ListActivity implements Runnable
Copyright (C) 2014 The Android Open Source Project Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

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


    
        
        super.onCreate(savedInstanceState);
        mUsageStatsManager = (UsageStatsManager) getSystemService(Context.USAGE_STATS_SERVICE);
        mLastTime = System.currentTimeMillis() - USAGE_STATS_PERIOD;

        mAdapter = new Adapter();
        setListAdapter(mAdapter);
    
protected voidonPause()

        super.onPause();
        mHandler.removeCallbacks(this);
    
protected voidonResume()

        super.onResume();
        run();
    
public voidrun()

        long now = System.currentTimeMillis();
        UsageEvents events = mUsageStatsManager.queryEvents(mLastTime, now);
        long lastEventTime = mAdapter.update(events);
        if (lastEventTime >= 0) {
            mLastTime = lastEventTime + 1;
        }
        mHandler.postDelayed(this, 1000 * 5);