Example usage for android.view Display getSupportedRefreshRates

List of usage examples for android.view Display getSupportedRefreshRates

Introduction

In this page you can find the example usage for android.view Display getSupportedRefreshRates.

Prototype

@Deprecated
public float[] getSupportedRefreshRates() 

Source Link

Document

Get the supported refresh rates of this display in frames per second.

Usage

From source file:com.android.tv.MainActivity.java

private void applyDisplayRefreshRate(float videoFrameRate) {
    boolean is24Fps = Math.abs(videoFrameRate - FRAME_RATE_FOR_FILM) < FRAME_RATE_EPSILON;
    if (mIsFilmModeSet && !is24Fps) {
        setPreferredRefreshRate(mDefaultRefreshRate);
        mIsFilmModeSet = false;/*  w w w .j av a  2 s  .  c o  m*/
    } else if (!mIsFilmModeSet && is24Fps) {
        DisplayManager displayManager = (DisplayManager) getSystemService(Context.DISPLAY_SERVICE);
        Display display = displayManager.getDisplay(Display.DEFAULT_DISPLAY);

        float[] refreshRates = display.getSupportedRefreshRates();
        for (float refreshRate : refreshRates) {
            // Be conservative and set only when the display refresh rate supports 24fps.
            if (Math.abs(videoFrameRate - refreshRate) < REFRESH_RATE_EPSILON) {
                setPreferredRefreshRate(refreshRate);
                mIsFilmModeSet = true;
                return;
            }
        }
    }
}