Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Display.getRefreshRate() giving me different values in different devices

Tags:

android

I'm using Display.getRefreshRate() to retrieve the refresh rate of my display. In an X10 Mini, the value returned is 0.325. In a Galaxy S, the value is 68.0. This doesn't make any sense to me. Any ideas?

like image 560
Yuyo Avatar asked Nov 13 '22 23:11

Yuyo


1 Answers

This appears to be a bug, though I haven't found any bug reports for it. The number I get out is also ~0.34, while I was expecting something like 60. I havent managed to find a meaningfull interpretation of 0.34 with regard to refreshrates, and so my solution was simply to "reject its truth and substitute my own" with the following code:

public float getRefreshRate() {
    final WindowManager wm = (WindowManager) getSystemService(Context.WINDOW_SERVICE);
    final Display display = wm.getDefaultDisplay();
    float rate = display.getRefreshRate();
    if (rate < 10.0f) {
        rate = 60.0f; //Default to something which seems to be a normal refreshrate on many phones
    }
    return rate;
}

This works great in my app. Hope this was helpfull!

like image 135
Lennart Rolland Avatar answered May 19 '23 19:05

Lennart Rolland