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.

This question appears to be off-topic. The users who voted to close gave this specific reason:

"Questions about writing and publishing Android apps, writing custom ROMs, and other topics that are primarily of concern to developers are off-topic. Consider taking advantage of other resources that may be appropriate for your question." – Matthew Read

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.
–
THelperNov 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 PatawariNov 9 '12 at 6:05

1 Answer
1

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.