Android Get screen density


Example

To get the screens density, we also can make use of the Windowmanagers DisplayMetrics. This is a quick example:

// Get density in dpi
DisplayMetrics metrics = new DisplayMetrics();
context.getWindowManager().getDefaultDisplay().getMetrics(metrics);
int densityInDpi =  metrics.densityDpi;