Skip to content

Instantly share code, notes, and snippets.

@manadream
Created March 21, 2015 16:45
Show Gist options
  • Save manadream/9a001a4aa28895f121f2 to your computer and use it in GitHub Desktop.
Save manadream/9a001a4aa28895f121f2 to your computer and use it in GitHub Desktop.
Commands for setting android device orientation from shell
# first turn off accelerometer controlling the orientation
adb shell content insert --uri content://settings/system --bind name:s:accelerometer_rotation --bind value:i:0
# then set orientation
shopt -s nocasematch
if [ "$ORIENTATION" == "portrait" ]
then
adb shell content insert --uri content://settings/system --bind name:s:user_rotation --bind value:i:0
elif [ "$ORIENTATION" == "landscape" ]
then
adb shell content insert --uri content://settings/system --bind name:s:user_rotation --bind value:i:1
fi
@AndroidDeveloperLB
Copy link

Is it possible to avoid turning off the auto-rotation?
Maybe, alternatively, get the current state of it, and restore it later?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment