Created
July 8, 2017 05:31
-
-
Save vinaysshenoy/097f741309b313034948824a8ae252b1 to your computer and use it in GitHub Desktop.
Fix incorrect density reporting
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Override | |
protected void attachBaseContext(Context newBase) { | |
final Resources resources = newBase.getResources(); | |
final DisplayMetrics displayMetrics = resources.getDisplayMetrics(); | |
if (displayMetrics.densityDpi != (int) displayMetrics.xdpi) { | |
Logger.debug(TAG, "Override configuration!"); | |
final Configuration configuration = resources.getConfiguration(); | |
configuration.densityDpi = (int) displayMetrics.xdpi; | |
super.attachBaseContext(newBase.createConfigurationContext(configuration)); | |
} else { | |
super.attachBaseContext(newBase); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment