Changing Android Device orientation with ADB

ShibMe picture ShibMe · Sep 16, 2014 · Viewed 51.6k times · Source

I'm using Android 4.4 on a real device and I want to set the device orientation via adb. I don't want it done with uiautomator since it won't last after the termination of the uiautomator code.

How can I do this?

Answer

user3855135 picture user3855135 · Sep 16, 2014

You may first need to turn off the automatic rotation:

adb shell content insert --uri content://settings/system --bind name:s:accelerometer_rotation --bind value:i:0

Rotate to landscape:

adb shell content insert --uri content://settings/system --bind name:s:user_rotation --bind value:i:1

Rotate portrait:

adb shell content insert --uri content://settings/system --bind name:s:user_rotation --bind value:i:0