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 size and density ?
You can also access the WindowManager through ADB:
$ adb shell wm usage: wm [subcommand] [options] wm size [reset|WxH] wm density [reset|DENSITY] wm overscan [reset|LEFT,TOP,RIGHT,BOTTOM]
To get the screen resolution:
$ adb shell wm size Physical size: 2880x1600
To get the screen the density:
$ adb shell wm density Physical density: 320
You can also override the density by adding the new density:
$ adb shell wm density 160
LCD density is in the build.prop:
adb shell getprop ro.sf.lcd_density
And the resolution is availble in the dumpsys of the input activity:
# windows adb shell dumpsys window | find "DisplayWidth" # linux adb shell dumpsys window | grep DisplayWidth
It works on all the devices I've tested with (2.2, 2.3.3, 2.3.4, 4.0.3; Acer Liquid E, HTC Wildfire S, HTC Incredible S, Motorola Atrix 4G, Samsung Galaxy Note, Samsung Galaxy Nexus), as well as the emulator, although the emulator's outputs are too clean to serve as a good example for parsing.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With