How to set device wide screen orientation

by Michel » Thu, 30 Jul 2009 01:21:04 GMT


Sponsored Links
 Hi androids,

This is my first message over here and I'm a starting android
developer so please be patient. Here's my case; I'm trying to create a
simple program that sets the device's screen orientation by the press
of a button. It's quite easy to set and change the orientation for the
current activity, but I want to set and keep the setting until the
button is pressed again like when the keyboard is slide out and back
in on a G1 or by the movementsensor.

I started with using the setRequestedOrientation() but I quickly found
that's only for the current activity, as soon is I close the activity
the screen returns to it's original state. I then found that it's
possible to set orientation with updateConfiguration()

Configuration config = new Configuration();
config.orientation = ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE;
getResources().updateConfiguration(config, getResources
().getDisplayMetrics());

but this doesn't seem to have any effect for what soever.

I've spent hours and hours googling for possible solutions but I'm
completely stuck and the only option I found was to emulate the
keyboard slide out and in, but besides the fact that I wouldn't know
how, that seems a bit of a big solution for what seems to be a simple
task.
I thought this would be easy (and maybe it is), can somebody help me
out or point me in the right direction?

Thanks in advance,
Michel

--~--~---------~--~----~------------~-------~--~----~



Other Threads

1. ListView OnItemClickListener no callback

You can't, it's one or the other. If you put a focusable widget in a
list item, that's what happens. If you need checkboxes, use ListView's
choice mode instead.






-- 
Romain Guy
Android framework engineer
romain...@android.com

Note: please don't send private questions to me, as I don't have time
to provide private support.  All such questions should be posted on
public forums, where I and others can see and answer them

--~--~---------~--~----~------------~-------~--~----~

2. Reference to port Linux programs to Android x86

I am new to Android porting but I think you may read this complete
guide to make a Linux From Scratch and I think that it may also help
Android x86 to be ported easier.

http://www.linuxfromscratch.org/lfs/read.html

Anyone who has ever built a Linux system from scratch understands how
the kernel and system works together. I hope it helps!.

Jorge Fernandez

--~--~---------~--~----~------------~-------~--~----~
unsubscribe: android-porting+unsubscr...@googlegroups.com
website: 

3. Embedded activityGroup and Dialog box

4. Center Text in a AlertDialog.Builder

5. aapt error with Standard menu icons (resource is not public)

6. Excluding test files from the compiled Android app

7. Overlay Interface