當前位置: 首頁>>代碼示例>>Java>>正文


Java SystemClock.elapsedRealtime方法代碼示例

本文整理匯總了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();
		}
	}
}
 
開發者ID:7763sea,項目名稱:VirtualHook,代碼行數:24,代碼來源:VAccountManagerService.java

示例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);

}
 
開發者ID:philipwhiuk,項目名稱:q-mail,代碼行數:26,代碼來源:StorageEditor.java

示例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;
  }
}
 
開發者ID:MLNO,項目名稱:airgram,代碼行數:20,代碼來源:MediaCodecVideoTrackRenderer.java

示例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;
}
 
開發者ID:Twelvelines,項目名稱:AndroidMuseumBleManager,代碼行數:27,代碼來源:CycledLeScanner.java

示例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;
}
 
開發者ID:JackChan1999,項目名稱:boohee_v5.6,代碼行數:23,代碼來源:BsDiffPatchInternal.java

示例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);
}
 
開發者ID:archos-sa,項目名稱:aos-Video,代碼行數:29,代碼來源:RemoteViewsFactoryBase.java

示例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;
}
 
開發者ID:archos-sa,項目名稱:aos-Video,代碼行數:12,代碼來源:MultiBackHintManager.java

示例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;
}
 
開發者ID:lsjwzh,項目名稱:FastTextView,代碼行數:9,代碼來源:TestListAdapter.java

示例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();
}
 
開發者ID:crazytaxii,項目名稱:Achilles_Android,代碼行數:12,代碼來源:CpuMonitor.java

示例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();
}
 
開發者ID:pooyafaroka,項目名稱:PlusGram,代碼行數:10,代碼來源:ChunkSampleSource.java

示例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;
}
 
開發者ID:JackChan1999,項目名稱:letv,代碼行數:14,代碼來源:Profiler.java

示例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);
}
 
開發者ID:sdrausty,項目名稱:buildAPKsSamples,代碼行數:16,代碼來源:CubeWallpaper2.java

示例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);
    }
}
 
開發者ID:JackChan1999,項目名稱:boohee_v5.6,代碼行數:30,代碼來源:AuthDialog.java

示例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);
}
 
開發者ID:Doist,項目名稱:JobSchedulerCompat,代碼行數:28,代碼來源:JobStoreTest.java

示例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);

}
 
開發者ID:googlecodelabs,項目名稱:android-lifecycles,代碼行數:16,代碼來源:LiveDataTimerViewModel.java


注:本文中的android.os.SystemClock.elapsedRealtime方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。