2

I want my application to exclusively run in portrait mode. I have tried different approaches :

  • declare android:screenOrientation="portrait" in the AndroidManifest file : seems useless.
  • put setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT) : prevents the application from changing to landscape mode when the phone is rotated to landscape mode after the start of the application but is unable to start the application in portrait mode when the phone is in landscape mode (in fact, the application crashes).

How can I do to always have my application run in portrait mode, no matter the orientation of the phone when the application is started?

Thanks in advance for the time you will spend trying to help me.

Zelig
  • 187
  • 3
  • 8

3 Answers3

2

add android:screenOrientation="portrait" to the activity in the manifest

josephus
  • 8,284
  • 1
  • 37
  • 57
1

Your query is already answered with Force "portrait" orientation mode

Sometimes a search helps give results faster.

Community
  • 1
  • 1
the100rabh
  • 4,077
  • 4
  • 32
  • 40
1

add android:screenOrientation="portrait" in every activity in menifest file of your android project.

Android Killer
  • 18,174
  • 13
  • 67
  • 90