Skip to content

Instantly share code, notes, and snippets.

@dominicthomas
Created January 4, 2014 16:40
Show Gist options
  • Save dominicthomas/8257190 to your computer and use it in GitHub Desktop.
Save dominicthomas/8257190 to your computer and use it in GitHub Desktop.
Android screen size with platform backwards compatibility.
private Point getScreenSize() {
Point size = new Point();
WindowManager w = getWindowManager();
if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
w.getDefaultDisplay().getSize(size);
}else{
Display d = w.getDefaultDisplay();
size.x = d.getWidth();
size.y = d.getHeight();
}
return size;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment