2

I making an app and im currently optimizing it to Samsung Galaxy Tab. I have a little problem here, when i launch the application, it is came up in only one portrait orientation.

I use this code:

android:screenOrientation="portrait"

It is only working with one portrait screen orientation, so if i rotate the device to upside down, its now changing. Its a little annoying, because if i start the application in the wrong orientation, my app came up in upside down and wont change.

What can i do with this ?

Adam Varhegyi
  • 11,307
  • 33
  • 124
  • 222

3 Answers3

3

Instead of setting android:screenOrientation="portrait" , you should set android:screenOrientation="sensorPortrait" if you are on API Level 9+.

For more info: check documentation.

Paresh Mayani
  • 127,700
  • 71
  • 241
  • 295
2

You can try Activity. setRequestedOrientation(int)

The parameter can be either ActivityInfo.SCREEN_ORIENTATION_PORTRAIT or ActivityInfo.SCREEN_ORIENTATION_SENSOR_PORTRAIT

papaiatis
  • 4,231
  • 4
  • 26
  • 38
0

In onCreate() before calling super.onCreate() call below method... it should work...

setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
Mohit Mehta
  • 1,283
  • 12
  • 21