title: Android Emulator Orientation Change Through Emulator Console or ADB
body: <p>I am trying to build an automated test framework for checking basic things that an app should respond to, without crashing. One of those is checking if an app responds to configuration change properly. Now, since it is automated, I have to switch the emulator's orientation between landscape and portrait and observe if it crashes, PROGRAMMATICALLY. [caps cuz there are many questions relating to ctrl+F12 or num pad 7]</p>
  <p>I am trying to figure out an adb or emulator console command to get this done.</p>
  <p>i did a telnet to localhost:5554 and entered the following commands:</p>
  <blockquote>
  <p>$sensor status // gives the enabled/disabled status of all sensors</p>
  </blockquote>
  <pre><code>acceleration: enabled.
  magnetic-field: enabled.
  orientation: enabled.
  temperature: enabled.
  proximity: enabled.
  OK
  </code></pre>
  <blockquote>
  <p>$sensor get orientation</p>
  </blockquote>
  <pre><code>orientation = 0:0:0
  </code></pre>
  <blockquote>
  <p>$sensor set orientation 90:0:0</p>
  </blockquote>
  <pre><code>OK
  </code></pre>
  <p>I tried different combinations of this and it doesn't respond. To get the value that is set when it is in landscape mode, I manually changed the orientation using ctrl+F12 and tried getting the orientation sensor status again, and to my dismay, the value didn't change.</p>
  <p><a href="http://discuz-android.blogspot.com/2008/01/change-android-screen-landscapeportrait.html" rel="nofollow noreferrer">A certain blog also mentioned this particular command in ADB</a></p>
  <blockquote>
  <p>$service call window 18 i32 1</p>
  <p>$service call window 18 i32 0</p>
  </blockquote>
  <p>for switching orientations. But, I get this error message</p>
  <blockquote>
  <p>Result: Parcel(fffffffc ffffffff   '........')</p>
  </blockquote>
  <p>It would be great if I could get a solution to this.</p>