本文整理汇总了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);
}
}
}