Get Size and Orientation of the Screen

/* First, get the Display from the WindowManager */
Display display = ((WindowManager) getSystemService(WINDOW_SERVICE)).getDefaultDisplay();

/* Now we can retrieve all display-related infos */
int width = display.getWidth();
int height = display.getHeight();
int orientation = display.getOrientation();

2 Comments

#
Sydney - December 7, 2009 at 2:59 p.m.

According to the discussion in the following thread, the orientation of the screen should not be retrieved in this way. Instead, getResources().getConfiguration().orientation should be used.

http://groups.google.com/group/android-developers/browse_thread/thread/805764447b58a816

#
andcoder - January 19, 2010 at 8:29 a.m.

here is a nice Example

http://www.ceveni.com/2009/08/how-to-get-screen-orientation-in.html

to get screen resolution and mode

Add a Comment