本文整理匯總了Java中android.view.Display.getRefreshRate方法的典型用法代碼示例。如果您正苦於以下問題:Java Display.getRefreshRate方法的具體用法?Java Display.getRefreshRate怎麽用?Java Display.getRefreshRate使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類android.view.Display
的用法示例。
在下文中一共展示了Display.getRefreshRate方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: getDisplayRefreshNsec
import android.view.Display; //導入方法依賴的package包/類
/**
* Obtains the approximate refresh time, in nanoseconds, of the default display associated
* with the activity.
* <p>
* The actual refresh rate can vary slightly (e.g. 58-62fps on a 60fps device).
*/
public static long getDisplayRefreshNsec(Activity activity) {
Display display = ((WindowManager)
activity.getSystemService(Context.WINDOW_SERVICE)).getDefaultDisplay();
double displayFps = display.getRefreshRate();
long refreshNs = Math.round(1000000000L / displayFps);
Log.d(TAG, "refresh rate is " + displayFps + " fps --> " + refreshNs + " ns");
return refreshNs;
}
示例2: run
import android.view.Display; //導入方法依賴的package包/類
public void run() {
if (mCurrentState == STATE_PREPARED) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
if (mWaitForNewRate) {
View v = mWindow.getDecorView();
Display d = v.getDisplay();
float currentRefreshRate = d.getRefreshRate();
if (Math.abs(mRefreshRate - currentRefreshRate) > .1) {
if (DBG) Log.d(TAG, "current refresh rate is " + currentRefreshRate + " trying to switch to " + mRefreshRate);
mHandler.postDelayed(mRefreshRateCheckerAsync, 200);
return;
}
if (DBG) Log.d(TAG, "refresh rate before video start is " + currentRefreshRate);
}
}
mCurrentState = STATE_REFRESH_PREPARED;
if (mVideoWidth != 0 && mVideoHeight != 0) {
mSurfaceController.setVideoSize(mVideoWidth, mVideoHeight, mVideoAspect);
if (mEffectRenderer != null)
mEffectRenderer.setVideoSize(mVideoWidth, mVideoHeight, mVideoAspect);
mHandler.removeCallbacks(mPreparedAsync);
mHandler.post(mPreparedAsync);
} else {
// We don't know the video size yet, but should start anyway.
// The video size might be reported to us later, or not at all.
// Wait 1 second, and play a video with no surface (sound only).
mHandler.postDelayed(mPreparedAsync, 1000);
}
}
}