Is it possible to make an app only run in the devices "true" orientation. For example on phone, lock the app to portrait and on tablet (if its orientation is meant to be landscape) lock to landscape.
-
2Why would the user want this? After all, since every "true orientation" combination is possible (smaller screens in portrait, smaller screens in landscape, larger screens in portrait, larger screens in landscape), your proposed limitation will not save you any development time. – CommonsWare Jun 23 '15 at 19:53
-
I agree with @CommonsWare. Is it to avoid the application crashing on rotation? – Rose R. Jun 23 '15 at 19:55
-
possible duplicate of [Control default auto rotate screen in my application](http://stackoverflow.com/questions/9718317/control-default-auto-rotate-screen-in-my-application) – Rose R. Jun 23 '15 at 20:36
1 Answers
You can force an activity into a certain mode (e.g. portrait or landscape). You can do so by adding the following to the parameters of your android manifest android:screenOrientation="portrait"
.
However, you will probably not want to do this. It will probably be considered annoying by a user unless you have a good reason (Ergo, Fallout Shelter by Bethesda is forced into landscape mode so you can see more of the screen, it can still flip to the other landscape direction, however.).
If it is to stop activities crashing on recreation, this avoids solving other problems which can cause critical failure. Being destroyed and recreated frequently is the natural life cycle of an activity (this is what happens when you rotate the screen). You can read more about activity life cycles here.

- 141
- 11