0

I'm working at a game, and the orientation is sensorLandscape.

<application
    android:allowBackup="true"
    android:icon="@drawable/ic_launcher"
    android:label="@string/app_name"
    android:theme="@style/GdxTheme" >
    <activity
        android:name="com.fainosag.marioskate.android.AndroidLauncher"
        android:label="@string/app_name" 
        android:screenOrientation="sensorLandscape"
        android:configChanges="keyboard|keyboardHidden|orientation|screenSize">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>
</application>

Now my game can flip when I rotate my phone. THe problem i have is that when the phone is flipped, the accelerometer value is also flipped..

How can I find out which android landscape orientation is ?

Boldijar Paul
  • 5,405
  • 9
  • 46
  • 94
  • 1
    Look at this question: http://stackoverflow.com/questions/2795833/check-orientation-on-android-phone – Fenix May 25 '14 at 17:07
  • That question is about how to get the screen orientation (portrait / landscape / square), I want to know which landscape orientation is..i think that i want to see if the rotation is 0 or 180 degrees (landscape and landscape flipped) – Boldijar Paul May 25 '14 at 17:10

1 Answers1

3

I can't comment because of low rep. (previous was just converted to comment)

So now I know what you want, I didn't understand you before. Try this:

WindowManager mWindowManager = (WindowManager) getSystemService(Context.WINDOW_SERVICE);    

Display display = mWindowManager.getDefaultDisplay();
int rotation = display.getRotation();

Check the degree with Surface.ROTATION_0 (no rotation), Surface.ROTATION_90, Surface.ROTATION_180, or Surface.ROTATION_270.

See also here: http://developer.android.com/reference/android/view/Display.html#getRotation() and here http://developer.android.com/reference/android/view/Surface.html

Fenix
  • 106
  • 1
  • 5