Take the 2-minute tour ×
Android Enthusiasts Stack Exchange is a question and answer site for enthusiasts and power users of the Android operating system. It's 100% free, no registration required.

I have developed an app and I need to test it. I have borrowed some devices from my friends and bought a few. Now problem is that I want to test it in both landscape mode and portrait mode but I don't want to keep on changing the orientation of phones every 5 minutes manually by myself.

Is there any adb command or anything else by which I can tell the phone to change its orientation? Can I fool it by simulating acceleration or any other alternative?

I am open to rooting but I prefer any solution which works on non-rooted phones.

share|improve this question
    
On this forum someone suggested to use the "flip" command from the monkey "test" program. However, this only works in the emulator, not in real devices. –  THelper Nov 8 '12 at 12:00
    
You could try echoing values to /sys/devices/virtual/accelerometer/accelerometer/acc_file or something similar, though I think that may require root. –  Matthew Read Nov 8 '12 at 17:13
    
This files doesn't exist in my phones. I am trying to locate the right location for this. Does the location vary from device to device, from Android's version to version? –  Aditya Patawari Nov 9 '12 at 6:05
add comment

1 Answer

I don't think you can do it via adb, but you can programmatically change the orientation using.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);

You could link this up to a timer that would change the orientation every five minutes if that's what you want to do, or write it into unit tests to automatically check if everything goes ok when you change orientation.

share|improve this answer
    
I think this has to go in the app which will require me to modify the xml code. I don't want to do that. Can I do it without playing with app's source? –  Aditya Patawari Nov 8 '12 at 11:45
    
No not really, it's something that you'd usually pick up at the unit testing level rather than trying to automate it after the app is complete. –  Sean O'Toole Nov 8 '12 at 11:51
    
So that means that there is NO way to change the orientation without modifying the app's source. –  Aditya Patawari Nov 8 '12 at 13:22
    
Not in the way you need to do it, no. –  Sean O'Toole Nov 8 '12 at 14:32
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.