I am working on a program that connects the phone to a screen that does not rotate. I have found a way to inject touch and key events. The only problem I am having is with getting it to stay in landscape. I have found that I can set USER_ROTATION and ACCELEROMETER_ROTATION in the settings. However if a program requests to go into portrait mode it gets stuck and never rotates out of it. Assuming the user has root access, how can I globally force everything to go in landscape?
4 Answers
You could force the activity to be set on Landscape only using the manifest
<activity android:screenOrientation="landscape" android:configChanges="orientation|keyboardHidden" android:name="....">
This should work, also you may need to override any orientation that may happen if a hardware keyboard was shown/hidden

- 21,163
- 5
- 52
- 56
-
This is not the question. Changing orientation in an activity is easy. I was asking how to do it globally. I posted the answer and marked it as accepted. – kagronick Oct 08 '12 at 15:10
I found the answer in the source code for this project. http://code.google.com/p/perapp It can be done by reading system logs and creating system level dialogs that are allowed to show on top of everything else. You can create them hidden and have them force the screen into landscape.

- 2,552
- 1
- 24
- 29
I'm not sure how you might achieve this, but keep in mind some parts of the OS are not meant to be rotated, or cannot be rotated (ie. your home screen will never rotate). You might have to resort to taking an image of what the screen is displaying, and then rotating it 90 degrees, and then displaying it on the target screen.

- 366
- 2
- 10
-
I can't do that. It sends the image over HDMI to a car stereo. The car stereo sends the touch events over bluetooth. Would listening to a broadcast work? How would something like Tasker go about doing it? – kagronick Sep 29 '12 at 21:05
-
Honestly I have no experience with either. Hopefully someone else can answer that. – AC Arcana Oct 06 '12 at 23:09
-
@ACArcana: Actually, your home screen *can* rotate. For example, when I [dock](https://play.google.com/store/devices/details/Vehicle_Dock?id=galaxy_nexus_hspa_car_dock&hl=en) my phone, the home screen rotates into landscape. – josh3736 Oct 08 '12 at 15:13
-
I think the ROM you are using must have this option, in some Samsung devices there is option to lock screen orientation (but its OS option).

- 12,304
- 8
- 54
- 77