This question already has an answer here:
Without any code snippet for the application, how to get screen resolution and length of the screen. How could I find whether the device is ldpi, mdpi , hdpi or xhdpi ?
This question already has an answer here:
Without any code snippet for the application, how to get screen resolution and length of the screen. How could I find whether the device is ldpi, mdpi , hdpi or xhdpi ?
Edit: use
DisplayMetrics
to get the density of the screenthis will return the int value that represents the following constants.
DisplayMetrics.DENSITY_LOW ,DisplayMetrics.DENSITY_MEDIUM, DisplayMetrics.DENSITY_HIGH, DisplayMetrics.DENSITY_XHIGH
This will return following constants based on thsi you can identify the device
Try this
Source Identifying screen resolutions
The density variable is a constant defined in DisplayMetrics corresponding to the different dpis.