Only allow app to run in default orientation

436 views Asked by At

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.

1

There are 1 answers

0
Rose R. On

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.