Get Size and Orientation of the Screen

3 votes · 1 comment

Get the current orientation and size of the screen with android.view.Display and WindowManager.

raw ·
copy
· download
/* 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();
Add a comment

1 Comment

display.getOrientation is deprecated in API v8. You should use display.getRotation() now.

Reply · Sept. 26, 2013, 8:12 p.m.