0

I have a special need for my app. I must force the app to work only in portrait mode, but i need to know when the user has moved the phone to landscape mode. Why? because i am displaying a opengl view with a texture image, and when the user changues the phone position to landscape mode i must rotate the polygon without reseting the activity. Then i must force portrait mode on manifest, because i dont want that my onCreate method gets called again.

Please, can someone tell me how to achieve this?

I know how to rotate the image, i only need to know when the user has moved the phone to landscape position, but with portrait forced on manifest.

Thanks

NullPointerException
  • 36,107
  • 79
  • 222
  • 382

2 Answers2

1

By "forced portrait", I assume you mean adding android:screenOrientation="portrait" in the manifest. All you need to do to know when orientation has changed is to also add android:configChanges="keyboardHidden|orientation" to the <activity> declaration in the manifest; and then override onConfigurationChanged() in your Activity.

Isn't this what you need? Doesn't this work?

curioustechizen
  • 10,572
  • 10
  • 61
  • 110
0

Read the following posts; If you set it to sensor and then check in your activity what orientation the phone is in you can take actions accordingly.

Force orientation Force "portrait" orientation mode

Then read this, specially the first answer with android:screenOrientation="sensor" Force an Android activity to always use landscape mode

http://developer.android.com/reference/android/content/res/Configuration.html#orientation

Community
  • 1
  • 1
Orlymee
  • 2,349
  • 1
  • 22
  • 24