diff --git a/mobile/android/base/GeckoAppShell.java b/mobile/android/base/GeckoAppShell.java index 6ce81de2bf98..e5a26e763951 100644 --- a/mobile/android/base/GeckoAppShell.java +++ b/mobile/android/base/GeckoAppShell.java @@ -109,6 +109,7 @@ public class GeckoAppShell static private File sCacheFile = null; static private int sFreeSpace = -1; static File sHomeDir = null; + static private int sDensityDpi = 0; private static HashMap> mEventListeners; @@ -928,9 +929,13 @@ public class GeckoAppShell } public static int getDpi() { - DisplayMetrics metrics = new DisplayMetrics(); - GeckoApp.mAppContext.getWindowManager().getDefaultDisplay().getMetrics(metrics); - return metrics.densityDpi; + if (sDensityDpi == 0) { + DisplayMetrics metrics = new DisplayMetrics(); + GeckoApp.mAppContext.getWindowManager().getDefaultDisplay().getMetrics(metrics); + sDensityDpi = metrics.densityDpi; + } + + return sDensityDpi; } public static void setFullScreen(boolean fullscreen) {