In my instrumental tests, I want to test something in landscape and portrait modes, so I would like to set the orientation before starting the tests. Is there a way to programmatically adjust the orientation of a device or emulator?
I know the setRequestedOrientation() method, but it works for a certain activity, if another action is triggered, I must remember that I need to call it again. Iโm looking for a way to set the orientation โgloballyโ so that every new action starts automatically with that orientation.
UPDATE:
The solution must meet two requirements: 1) it does not force me to change my production code, 2) it must be run in the CI environment.
source share