-3

Possible Duplicate: How to disable orientation change in Android?

I'm trying to produce an Android application. How can I prevent the application to rotate to the right and to the left even when the user rotates their device?

Community
  • 1
  • 1
Itzick Binder
  • 175
  • 1
  • 4
  • 18

1 Answers1

2

By setting the orientation you want in the manifest...

Example: Add android:screenOrientation="portrait" to the element in the manifest or landscape:

<application android:icon="@drawable/icon"
             android:label="@string/app_name">
    <activity android:name="QRCodeActivity"
              android:label="@string/app_name"
              android:screenOrientation="landscape" >
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>
</application>

Also check Stack Overflow question Prevent screen rotation on Android.

Community
  • 1
  • 1
Nermeen
  • 15,883
  • 5
  • 59
  • 72
  • I tried to place that line in the xml file in the . It didn't help me. Can you be a little more specific where to place that line? – Itzick Binder Oct 26 '12 at 09:07
  • I tried this also and it didn't help, in addition I tried the other question that you mentioned. Perhaps you didn't understand me. I'm looking for a way that the application won't change and won't rotate even if the user tilt its phone – Itzick Binder Oct 26 '12 at 19:32