REQUESTING HELP: How to determine screen orientation?

Put your problem here if it does not fit any of the other categories.

REQUESTING HELP: How to determine screen orientation?

Postby Xeno » Fri Oct 31, 2008 5:13 pm

How can I determine the current orientation of the screen between portrait and landscape?
I am currently using this code:
Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1.  
  2. if (getRequestedOrientation() == ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE) {
  3.  
  4.     // do work
  5.  
  6. }
  7.  
  8.  
Parsed in 0.030 seconds, using GeSHi 1.0.8.4


but this doesn't seem to work at all. Maybe I'm doing something wrong? But I am trying to determine when the G1 is flipped open(landscape) to when it is closed. Any help would be much appreciated. Thanks!
I think, therefore I am.
I think, therefore I think I am.
Xeno
Freshman
Freshman
 
Posts: 6
Joined: Fri Oct 31, 2008 5:02 pm

Top

Postby jasont » Fri Oct 31, 2008 6:05 pm

You could grab the current width and height. If width is greater then the device is in landscape mode, if height is greater then the device is in portrait mode.
jasont
Developer
Developer
 
Posts: 28
Joined: Mon Sep 22, 2008 6:39 pm
Location: California

HeightWidth?

Postby Xeno » Fri Oct 31, 2008 6:06 pm

What happens if the user starts the App in Landscape mode instead of Portrait mode?
I think, therefore I am.
I think, therefore I think I am.
Xeno
Freshman
Freshman
 
Posts: 6
Joined: Fri Oct 31, 2008 5:02 pm

Property?

Postby Xeno » Fri Oct 31, 2008 6:40 pm

There has to be a specific property that returns the orientation of the screen. I refuse to believe I have to determine width/height just to determine orientation.
I think, therefore I am.
I think, therefore I think I am.
Xeno
Freshman
Freshman
 
Posts: 6
Joined: Fri Oct 31, 2008 5:02 pm

Thanks jasont

Postby Xeno » Fri Oct 31, 2008 9:39 pm

jasont wrote:You could grab the current width and height. If width is greater then the device is in landscape mode, if height is greater then the device is in portrait mode.


I ended up taking your advice and determining landscape/portrait via height/width. I don't like this method, it feels "dirty" per say lol, but works. If anyone out there can show an example of retieiving the screen orientation without determining height/width of the screen would be much appreciated.

Again, thanks jasont!
I think, therefore I am.
I think, therefore I think I am.
Xeno
Freshman
Freshman
 
Posts: 6
Joined: Fri Oct 31, 2008 5:02 pm

Top

Return to Other Coding-Problems

Who is online

Users browsing this forum: No registered users and 17 guests