Reputation: 9894
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 ?
Upvotes: 2
Views: 1763
Reputation: 1285
In onCreate() before calling super.onCreate() call below method... it should work...
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
Upvotes: 0
Reputation: 4291
You can try Activity. setRequestedOrientation(int)
The parameter can be either ActivityInfo.SCREEN_ORIENTATION_PORTRAIT
or ActivityInfo.SCREEN_ORIENTATION_SENSOR_PORTRAIT
Upvotes: 2
Reputation: 128428
Instead of setting android:screenOrientation="portrait"
,
you should set android:screenOrientation="sensorPortrait"
if you are on API Level 9+.
For more info: check documentation.
Upvotes: 3