On mdpi device I would like to call this method:
final float scale = getResources().getDisplayMetrics().density;
double height_px = 45 * scale + 0.5;
but I want to ignore the method when the app is run on hdpi devices, how am I able to determine the screen size on my class?
Yeah simply you can check for scale value like this,
And now you have scale value. The scale value varies like this,
For MDPI devices, scale value is 1.0.
For LDPI devices, scale value is 0.75.
For HDPI devices, scale value is 1.50.
For XHDPI devices, scale value is 2.0.
Just make a cross check,
Which means this code will not be executed for High and above resolutions.