1

I want to know if there was good way to keep my application from rotating, but let it go switch from landscape to landscape reversed?

I've only found this:

setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);

How can I restrict my applications to those two states?

AlfredoG
  • 43
  • 2
JoJoPla
  • 99
  • 1
  • 7
  • You can do it from the manifest thanks to android:screenOrientation="sensorLandscape" since API 9 (http://developer.android.com/guide/topics/manifest/activity-element.html) – Gorcyn Feb 17 '15 at 09:16

5 Answers5

3

Don't wanna say it but RTM !

Here, in your Manifest add this to your activity you wanna let rotate :

android:screenOrientation="sensorLandscape"
Funk Forty Niner
  • 74,450
  • 15
  • 68
  • 141
Ektos974
  • 999
  • 10
  • 30
  • sorry, I've missed that one, but i've read the doc about activity :/ Funny though the RTFM xD – JoJoPla Feb 17 '15 at 09:30
  • @zlgdev Please, do you think you could give me some advice/ideas over here http://goo.gl/E37NSu – eddy Mar 01 '15 at 15:45
0

Try adding this to your <activity> tag in the AndroidManifest.xml

android:screenOrientation="sensorLandscape"

Or if you want to do it programmatically you can add this to your activity

if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.GINGERBREAD) {
        setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE);
    }
timbillstrom
  • 1,176
  • 16
  • 33
0

have a look here (duplicate)

Force an Android activity to always use landscape mode

You have to define this in the manifest

Community
  • 1
  • 1
Dogosh
  • 151
  • 10
0

You just need to do one thing, just put android:screenOrientation="landscape" in every <activity> tag of your manifest file

Apurva
  • 7,871
  • 7
  • 40
  • 59
0

Just add the following line to activities added in Manifests

<activity android:name=".youractivityName" android:screenOrientation="portrait"  />
Ameer
  • 2,709
  • 1
  • 28
  • 44