0

as in the topic, ive got a trouble with locking screen orientation after its been locked in device's settings. Its a landscape app. Ive read couple threads about similar problem but havent got any revelant answer. Thanks in advance Mac

Dreamwalker
  • 3,032
  • 4
  • 30
  • 60
Maciej Boguta
  • 1,354
  • 1
  • 12
  • 15

3 Answers3

0

You can add android:screenOrientation="landscape" in your activity tag to specify the mode of screen orientation in your manifest file

<activity
            android:name="com.xyz.myapp.SplashActivity"
            android:label="@string/app_name"
            android:screenOrientation="landscape" >

Hope it helps .

Rachita Nanda
  • 4,509
  • 9
  • 42
  • 66
0

Add setRequestedOrientation in the onCreate method like below

 @Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    this.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
    setContentView(R.layout.homepage);
Beginner
  • 1,414
  • 2
  • 21
  • 41
  • ive got it set as SCREEN_ORIENTATION_SENSOR_LANDSCAPE, cuz I want it to be rotable whenever the device's setting for "auto rotate" is on, and to keep the landscape rotation whenever its off – Maciej Boguta Oct 01 '13 at 09:48
0

This would set to landscape if auto_rotate is off, otherwise if would rotate normally as long as it wasn't set to land/port in the manifest.

if(android.provider.Settings.System.getInt(getContentResolver(),Settings.System.ACCELEROMETER_ROTATION, 0) != 1){
   this.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
}
a54studio
  • 965
  • 11
  • 11