本文整理汇总了Java中android.os.SystemClock.elapsedRealtime方法的典型用法代码示例。如果您正苦于以下问题:Java SystemClock.elapsedRealtime方法的具体用法?Java SystemClock.elapsedRealtime怎么用?Java SystemClock.elapsedRealtime使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.os.SystemClock
的用法示例。
在下文中一共展示了SystemClock.elapsedRealtime方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: Session
import android.os.SystemClock; //导入方法依赖的package包/类
Session(IAccountManagerResponse response, int userId, AuthenticatorInfo info, boolean expectActivityLaunch, boolean stripAuthTokenFromResult, String accountName, boolean authDetailsRequired, boolean updateLastAuthenticatedTime) {
if (info == null) throw new IllegalArgumentException("accountType is null");
this.mStripAuthTokenFromResult = stripAuthTokenFromResult;
this.mResponse = response;
this.mUserId = userId;
this.mAuthenticatorInfo = info;
this.mExpectActivityLaunch = expectActivityLaunch;
this.mCreationTime = SystemClock.elapsedRealtime();
this.mAccountName = accountName;
this.mAuthDetailsRequired = authDetailsRequired;
this.mUpdateLastAuthenticatedTime = updateLastAuthenticatedTime;
synchronized (mSessions) {
mSessions.put(toString(), this);
}
if (response != null) {
try {
response.asBinder().linkToDeath(this, 0 /* flags */);
} catch (RemoteException e) {
mResponse = null;
binderDied();
}
}
}
示例2: commitChanges
import android.os.SystemClock; //导入方法依赖的package包/类
private void commitChanges() {
long startTime = SystemClock.elapsedRealtime();
Timber.i("Committing preference changes");
Runnable committer = new Runnable() {
public void run() {
for (String removeKey : removals) {
storage.remove(removeKey);
}
Map<String, String> insertables = new HashMap<String, String>();
for (Entry<String, String> entry : changes.entrySet()) {
String key = entry.getKey();
String newValue = entry.getValue();
String oldValue = snapshot.get(key);
if (removals.contains(key) || !newValue.equals(oldValue)) {
insertables.put(key, newValue);
}
}
storage.put(insertables);
}
};
storage.doInTransaction(committer);
long endTime = SystemClock.elapsedRealtime();
Timber.i("Preferences commit took %d ms", endTime - startTime);
}
示例3: isReady
import android.os.SystemClock; //导入方法依赖的package包/类
@Override
protected boolean isReady() {
if (super.isReady() && (renderedFirstFrame || !codecInitialized()
|| getSourceState() == SOURCE_STATE_READY_READ_MAY_FAIL)) {
// Ready. If we were joining then we've now joined, so clear the joining deadline.
joiningDeadlineUs = -1;
return true;
} else if (joiningDeadlineUs == -1) {
// Not joining.
return false;
} else if (SystemClock.elapsedRealtime() * 1000 < joiningDeadlineUs) {
// Joining and still within the joining deadline.
return true;
} else {
// The joining deadline has been exceeded. Give up and clear the deadline.
joiningDeadlineUs = -1;
return false;
}
}
示例4: deferScanIfNeeded
import android.os.SystemClock; //导入方法依赖的package包/类
/**
* check is defter scan
* @return
*/
private boolean deferScanIfNeeded(){
long millisecondsUntilStart = nextScanStartTime - SystemClock.elapsedRealtime();
if (millisecondsUntilStart > 0) {
if (isPrintCycleTime){
Logger.d("Waiting to start next Bluetooth scan for another "+millisecondsUntilStart+" milliseconds");
}
// Don't actually wait until the next scan time -- only wait up to 1 second. This
// allows us to start scanning sooner if a consumer enters the foreground and expects
// results more quickly.
mHandler.postDelayed(new Runnable() {
@Override
public void run() {
if (!isPauseScan) {
scanLeDevice(true);
}
}
}, millisecondsUntilStart > 1000 ? 1000 : millisecondsUntilStart);
return true;
}
Logger.d("Start cycle scan");
return false;
}
示例5: tryRecoverLibraryFiles
import android.os.SystemClock; //导入方法依赖的package包/类
protected static boolean tryRecoverLibraryFiles(Tinker manager, ShareSecurityCheck checker,
Context context, String
patchVersionDirectory, File
patchFile, boolean isUpgradePatch) {
if (manager.isEnabledForNativeLib()) {
String libMeta = (String) checker.getMetaContentMap().get(ShareConstants.SO_META_FILE);
if (libMeta == null) {
TinkerLog.w(TAG, "patch recover, library is not contained", new Object[0]);
return true;
}
long begin = SystemClock.elapsedRealtime();
long cost = SystemClock.elapsedRealtime() - begin;
TinkerLog.i(TAG, "recover lib result:%b, cost:%d, isUpgradePatch:%b", Boolean.valueOf
(patchLibraryExtractViaBsDiff(context, patchVersionDirectory, libMeta,
patchFile, isUpgradePatch)), Long.valueOf(cost), Boolean.valueOf
(isUpgradePatch));
return patchLibraryExtractViaBsDiff(context, patchVersionDirectory, libMeta,
patchFile, isUpgradePatch);
}
TinkerLog.w(TAG, "patch recover, library is not enabled", new Object[0]);
return true;
}
示例6: onContentChanged
import android.os.SystemClock; //导入方法依赖的package包/类
/*****************************************************************
** Addditional API
*****************************************************************/
/*
* Called when the contents of the cursor(s) used to get the data for this service changes
*/
public void onContentChanged() {
// We want the provider to handle the event and take care of reloading the data but we don't want the widget
// to be redrawn too often if the ContentObserver triggers a lot of events => schedule a delayed intent
// to the provider but make sure to cancel the previous intent which was scheduled so that the provider will only
// receive one intent after the last event is triggered.
long currentElapsedRealTime = SystemClock.elapsedRealtime();
if (DBG) Log.d(TAG, "onContentChanged : elapsed time since the last SHOW_UPDATE_SPINBAR_ACTION was sent = " + (currentElapsedRealTime - mLastShowSpinbarTime));
if (currentElapsedRealTime - mLastShowSpinbarTime > 1000) {
// Tell the provider to hide the RollView and show the spinbar
// NOTE : it should be enough to send this intent once (for instance when onContentChanged() is called
// for the first time after a while) but it is safer to send it periodically in case another event
// causes the widget to be redrawn
setDelayedAlarm(WidgetProviderVideo.SHOW_UPDATE_SPINBAR_ACTION, UPDATE_ACTION_DELAY, false);
mLastShowSpinbarTime = currentElapsedRealTime;
}
if (DBG) Log.d(TAG, "onContentChanged : replace previous RELOAD_ACTION at " + currentElapsedRealTime);
replacePreviousDelayedAlarm(WidgetProviderVideo.RELOAD_ACTION, RELOAD_ACTION_DELAY);
}
示例7: onBackPressed
import android.os.SystemClock; //导入方法依赖的package包/类
/** Must be called each time a BACK press is detected */
public void onBackPressed() {
long now = SystemClock.elapsedRealtime();
if (!sHideHint && (now - mPreviousPreviousPressTime < DETECTION_PERIOD)) {
Toast.makeText(mContext, R.string.leanback_hint_long_press_on_back, Toast.LENGTH_SHORT).show();
// reset timings to not have toast twice when pressing back 4 times
mPreviousPressTime = mPreviousPreviousPressTime = 0;
}
mPreviousPreviousPressTime = mPreviousPressTime;
mPreviousPressTime = now;
}
示例8: getView
import android.os.SystemClock; //导入方法依赖的package包/类
@Override
public final View getView(int position, View convertView, ViewGroup parent) {
long start = SystemClock.elapsedRealtime();
convertView = bindView(position, convertView, parent);
long end = SystemClock.elapsedRealtime();
bindCost += (end - start);
return convertView;
}
示例9: CpuMonitor
import android.os.SystemClock; //导入方法依赖的package包/类
public CpuMonitor(Context context) {
Log.d(TAG, "CpuMonitor ctor.");
appContext = context.getApplicationContext();
userCpuUsage = new MovingAverage(MOVING_AVERAGE_SAMPLES);
systemCpuUsage = new MovingAverage(MOVING_AVERAGE_SAMPLES);
totalCpuUsage = new MovingAverage(MOVING_AVERAGE_SAMPLES);
frequencyScale = new MovingAverage(MOVING_AVERAGE_SAMPLES);
lastStatLogTimeMs = SystemClock.elapsedRealtime();
scheduleCpuUtilizationTask();
}
示例10: onLoadError
import android.os.SystemClock; //导入方法依赖的package包/类
@Override
public void onLoadError(Loadable loadable, IOException e) {
currentLoadableException = e;
currentLoadableExceptionCount++;
currentLoadableExceptionTimestamp = SystemClock.elapsedRealtime();
notifyLoadError(e);
chunkSource.onChunkLoadError(currentLoadableHolder.chunk, e);
updateLoadControl();
}
示例11: getDurationII
import android.os.SystemClock; //导入方法依赖的package包/类
public long getDurationII() {
long elapsedRealtime = SystemClock.elapsedRealtime();
int i = bО041EО041EОО;
switch ((i * (b041E041EО041EОО + i)) % bОО041E041EОО) {
case 0:
break;
default:
bО041EО041EОО = b041EО041E041EОО();
b041E041EО041EОО = 42;
break;
}
return elapsedRealtime - this.mStartTimeII;
}
示例12: CubeEngine
import android.os.SystemClock; //导入方法依赖的package包/类
CubeEngine() {
// Create a Paint to draw the lines for our cube
final Paint paint = mPaint;
paint.setColor(0xffffffff);
paint.setAntiAlias(true);
paint.setStrokeWidth(2);
paint.setStrokeCap(Paint.Cap.ROUND);
paint.setStyle(Paint.Style.STROKE);
mStartTime = SystemClock.elapsedRealtime();
mPrefs = CubeWallpaper2.this.getSharedPreferences(SHARED_PREFS_NAME, 0);
mPrefs.registerOnSharedPreferenceChangeListener(this);
onSharedPreferenceChanged(mPrefs, null);
}
示例13: onReceivedError
import android.os.SystemClock; //导入方法依赖的package包/类
public void onReceivedError(WebView webView, int i, String str, String str2) {
super.onReceivedError(webView, i, str, str2);
f.c(AuthDialog.a, "-->onReceivedError, errorCode: " + i + " | description: " + str);
if (!Util.checkNetWork(this.a.l)) {
this.a.c.onError(new UiError(9001, "当前网络不可用,请稍后重试!", str2));
this.a.dismiss();
} else if (this.a.p.startsWith(ServerSetting.DOWNLOAD_QQ_URL)) {
this.a.c.onError(new UiError(i, str, str2));
this.a.dismiss();
} else {
long elapsedRealtime = SystemClock.elapsedRealtime() - this.a.r;
if (this.a.o >= 1 || elapsedRealtime >= this.a.s) {
this.a.k.loadUrl(this.a.b());
return;
}
this.a.o = this.a.o + 1;
this.a.e.postDelayed(new Runnable(this) {
final /* synthetic */ LoginWebViewClient a;
{
this.a = r1;
}
public void run() {
this.a.a.k.loadUrl(this.a.a.p);
}
}, 500);
}
}
示例14: testMassivePeriodClampedOnRead
import android.os.SystemClock; //导入方法依赖的package包/类
@Test
public void testMassivePeriodClampedOnRead() throws Exception {
long period = TimeUnit.HOURS.toMillis(2);
JobInfo job = JobCreator.create(context, 8).setPeriodic(period).setPersisted(true).build();
long invalidLateRuntimeElapsedMillis = SystemClock.elapsedRealtime() + (period) + period; // > period.
long invalidEarlyRuntimeElapsedMillis = invalidLateRuntimeElapsedMillis - period; // Early = (late - period).
JobStatus jobStatus =
new JobStatus(job, "noop", invalidEarlyRuntimeElapsedMillis, invalidLateRuntimeElapsedMillis);
jobStore.add(jobStatus);
waitForJobStoreWrite();
JobStore.JobSet jobStatusSet = new JobStore.JobSet();
jobStore.readJobMapFromDisk(jobStatusSet);
assertEquals("Incorrect # of persisted tasks.", 1, jobStatusSet.size());
JobStatus loaded = jobStatusSet.getJobs().iterator().next();
// Assert early runtime was clamped to be under now + period. We can do <= here b/c we'll
// call SystemClock.elapsedRealtime after doing the disk i/o.
long newNowElapsed = SystemClock.elapsedRealtime();
assertTrue("Early runtime wasn't correctly clamped.",
loaded.getEarliestRunTimeElapsed() <= newNowElapsed + period);
// Assert late runtime was clamped to be now + period + flex.
assertTrue("Early runtime wasn't correctly clamped.",
loaded.getEarliestRunTimeElapsed() <= newNowElapsed + period);
}
示例15: LiveDataTimerViewModel
import android.os.SystemClock; //导入方法依赖的package包/类
public LiveDataTimerViewModel() {
mInitialTime = SystemClock.elapsedRealtime();
Timer timer = new Timer();
// Update the elapsed time every second.
timer.scheduleAtFixedRate(new TimerTask() {
@Override
public void run() {
final long newValue = (SystemClock.elapsedRealtime() - mInitialTime) / 1000;
// setValue() cannot be called from a background thread so post to main thread.
mElapsedTime.postValue(newValue);
}
}, ONE_SECOND, ONE_SECOND);
}