Rotate Screen from Code
What you learn: You will learn how to rotate the screen (change screen orientation) using code.
[Update]
zhobbs wrote:
Thanks for the tip plusminus, looks like it changed in 0.9: Java:
Activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_*);
and Java:
Activity.getRequestedOrientation();
Thanks!
[/Update]
(Just found this code snippet in my ICQ-Log): Java:
android.view.IWindowManager windowService = android.view.IWindowManager.Stub.asInterface(ServiceManager.getService("window"));
windowService.setOrientation(1);
If I remember right, it is 0-3 for all 4 possible screen-rotations (could not find official constants for it
).
The orientation is even "remembered" if you leave your app to the HOME-Screen.
This is how to get the current Screen-Orientation: Java:
windowService.getOrientation();