views:

764

answers:

4

I'm trying to write a program that needs smooth orientation sensor samples as the phone is rotated all around. Every time the orientation of the phone is changed, it interrupts the data and freezes the program while the layout changes. How can I lock it in one orientation (landscape or portrait, it doesn't matter)?

I assume it has something to do with android:layout in the xml file, but I can't find anything online.

A: 

simplest and one of ways to do this would be having android:screenOrientation="portrait|landscape"
property in every activity in your manifest file.

Samuh
+1  A: 

This answer looks promising to me (used [android] [screen-orientation] in the SO search box)

Andreas_D
A: 

The above never seems to work for me.

I always use:-

setRequestedOrientation(0);

Changing the value at the end will give horizintal/vertical lock. Make sure to catch the keyboard being opened in the manifest though, if in portrait mode, as it may give unexpected results.

andy_spoo
A: 

u can use this syntax in the manifest file for perticular activity ,android:configChanges="keyboardHidden|orientation"

murali.dhuli