Question

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 ?

Was it helpful?

Solution

You can try Activity. setRequestedOrientation(int)

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

OTHER TIPS

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

For more info: check documentation.

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

setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top