15

In my app I'm using the following command :

Settings.System.putInt(getContentResolver(), Settings.System.USER_ROTATION, m_lockedInOrientation)

As mentioned in the Android site this will set the default orientation when android can't find one. :

Default screen rotation when no other policy applies. When ACCELEROMETER_ROTATION is zero and no on-screen Activity expresses a preference, this rotation value will be used.

Currently this is the only reason why my app is not working on Android 2.X but only 3.X+ ..
Does anyone aware of a way to workaround it ?

Vishal Yadav
  • 3,642
  • 3
  • 25
  • 42
SagiLow
  • 5,721
  • 9
  • 60
  • 115
  • 1
    Knowing why you need to set this system preference would be useful. I you only need to control your own application's default rotation, then there's a different way to do this. If you are really needing to set this preference system-wide then there's probably not a workaround as this setting simply doesn't exist on Android < honeycomb. – Brett Duncavage Apr 05 '13 at 02:34
  • The app is a tool for controlling the system orientation , so it's not only for my app – SagiLow Apr 05 '13 at 05:43
  • If you want to override other apps' orientations rather than just specify the default system orientation, take a look at [How can I globally force screen orientation in Android?](http://stackoverflow.com/questions/14587085/how-can-i-globally-force-screen-orientation-in-android). – Sam May 05 '15 at 12:52
  • Use getRotation() method. https://developer.android.com/reference/android/view/Display.html#getRotation() – hkaraoglu Dec 15 '16 at 08:30

1 Answers1

0
 //vetical position
    setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT); // Make to run your application only in portrait mode
  //HORIZONDEL setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_SCREEN_ORIENTATION_LANDSCAPE);
Akash pasupathi
  • 304
  • 1
  • 14