Search code examples
androidscreen-orientationnexus-7adb

ADB shell monkey command changing device orientation lock


I'm using the adb shell command monkey to launch one application followed by another. It all works fine, except for one odd side effect where the orientation lock on the device is set back to auto-rotate. We usually have the tablets locked to portrait only.

Is anyone aware of any reason the monkey command would change the orientation lock? Or if there is a way to prevent this/set it back through the adb?

adb shell monkey -p com.application1 1
adb shell monkey -p com.application2 1

Tablet Info:

  • Nexus 7
  • Android v6.0.1

Solution

  • As discussed in the comments above with @MartinZeitler, the problem was that the monkey command was not really suitable for the purpose I was putting it to. Although removing the orientation lock is not something I've been able to find explicitly documented anywhere, it looks as if this is one of the random elements monkey triggers.

    My solution was to launch the application using the following command, which was more appropriate for just launching an application as part of another test rather than using the stress test command.

    am start -n com.application1/.MainActivity`
    

    The following Question contains some really good detail on launching apps through the ADB

    How to start an application using android ADB tools?