How to check an Android device is HDPI screen or MDPI screen?

virsir picture virsir · Feb 24, 2011 · Viewed 66.3k times · Source

I want to check this to fetch different images by internet. How to do that?

Answer

SteD picture SteD · Feb 24, 2011
density = getResources().getDisplayMetrics().density;

// return 0.75 if it's LDPI
// return 1.0 if it's MDPI
// return 1.5 if it's HDPI
// return 2.0 if it's XHDPI
// return 3.0 if it's XXHDPI
// return 4.0 if it's XXXHDPI