Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get the Android device screen size from the adb command line?

Tags:

android

adb

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 ?

like image 727
user954469 Avatar asked Sep 23 '11 10:09

user954469


2 Answers

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 
like image 193
Albert-Jan Verhees Avatar answered Sep 18 '22 21:09

Albert-Jan Verhees


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.

like image 41
Nisan.H Avatar answered Sep 22 '22 21:09

Nisan.H