I need a way to detect device screen size and density with adb. If there is no solution, where can I get the complete list of all existing android device with their screen
To get required info from ADB, the following command executed from the command line will return a lot of useful properties about the connected devices
> adb shell getprop
To filter through these properties
on Unix use grep like
> adb shell getprop | grep density
on Windows use find like
> adb shell getprop | findstr "density"
Returned value looks like
[ro.sf.lcd_density]: [240]
for screen size put display instead of density
You can get screen dimensions with this code:
public int getScreenHeight() {
return getDisplay().getHeight();
}
private Display getDisplay() {
return ((WindowManager) getContext().getSystemService(
Context.WINDOW_SERVICE)).getDefaultDisplay();
}
public int getScreenWidth() {
return getDisplay().getWidth();
}
Once you have the Display in the code above you can use DisplayMetrics to get the density. DisplayMetrics will also give you absolute display with and height.
ANDROID:/ # dumpsys window | grep mGlobalConfiguration
mGlobalConfiguration={1.0 ?mcc?mnc [en_US] ldltr sw720dp w1920dp h532dp 160dpi
So resolution is 1920x720