I want to check this to fetch different images by internet. How to do that?
You can check the screen density with:
switch (getResources().getDisplayMetrics().densityDpi) {
case DisplayMetrics.DENSITY_LOW:
// ...
break;
case DisplayMetrics.DENSITY_MEDIUM:
// ...
break;
case DisplayMetrics.DENSITY_HIGH:
// ...
break;
case DisplayMetrics.DENSITY_XHIGH:
// ...
break;
}
EDIT Be aware that as Android evolves, other values should be included in the switch
cases. As of this edit, this includes DisplayMetrics.DENSITY_TV
and DisplayMetrics.DENSITY_XXHIGH
. Consult the docs for the latest info; I'm not going to bother maintaining this answer.