UsageLogActivitypublic class UsageLogActivity extends android.app.ListActivity implements RunnableCopyright (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 |
Methods Summary |
---|
protected void | onCreate(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 void | onPause()
super.onPause();
mHandler.removeCallbacks(this);
| protected void | onResume()
super.onResume();
run();
| public void | run()
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);
|
|