I have an Android PC with root (out-of-box) connected to an external monitor (HDMI & USB) that always displays in landscape, even though my app specifies portrait in the activity declaration in Manifest:
android:screenOrientation="portrait"
I am trying to execute the following command from this SO post to force portrait:
proc = Runtime.getRuntime().exec("adb shell content insert --uri content://settings/system --bind name:s:user_rotation --bind value:i:0");
int exitVal = proc.waitFor();
This should set the screen to portrait, but the display always remains in landscape. No exceptions are recorded.
I have also used the following without success:
process = Runtime.getRuntime().exec("content insert --uri content://settings/system --bind name:s:user_rotation --bind value:i:0");
process = Runtime.getRuntime().exec(new String[]{"su","-c","content insert --uri content://settings/system --bind name:s:user_rotation --bind value:i:0"});
In both cases, the exit value is [0]. Which means the command terminated normally.
There is only one USB port, and one micro USB port (Power only/no data) on the Android PC. With debugging enabled, I cannot enumerate the device in DDMS, nor execute shell commands from BASH connecting my dev PC to the micro USB port on the Android PC. So, I am trying to do this from my Android app.
Please advise