Saturday, August 20, 2011

[android-developers] getOrientation() madness

Using API version 7, this code produces the exact opposite results on
my Evo versus my Galaxy Tab:

switch( getWindowManager().getDefaultDisplay().getOrientation() )
{
case 0:
display_mode = MyApplication.HORIZONTAL;
break;

case 1:
display_mode = MyApplication.VERTICAL;
break;

case 2:
display_mode = MyApplication.HORIZONTAL;
break;

case 3:
display_mode = MyApplication.VERTICAL;
break;
}

log( "display_mode: " + ( display_mode == MyApplication.HORIZONTAL
? "HORIZONTAL" : "VERTICAL" ) );


I switched to API version 13 to see if the problem was fixed in the
future, and it also tells lies from one device to another.


I have dynamic full screen graphics that cannot be skewed. I'm having
to write code to compensate for the Galaxy Tab's 48 pixel bar at the
bottom. getWindowManager().getDefaultDisplay().getHeight() says it's
800 but it's really only 752 due to the bar. Now I find I cannot even
count on the display orientation being accurate to code up a fix for
the initial problem.


So how do I contend with this mess?

What other devices can I count on to lie about their display and orientation?

--
Greg Donald

--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

No comments:

Post a Comment