Skip to content

Instantly share code, notes, and snippets.

@davetrux
Last active December 15, 2015 12:19
Show Gist options
  • Save davetrux/5259897 to your computer and use it in GitHub Desktop.
Save davetrux/5259897 to your computer and use it in GitHub Desktop.
Using newer Android APIs in an older version
/*
* Handles Gingerbread crash due to implementation change
*/
private static Point getDisplaySize(final Display display) {
if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
return APIv11.getDisplaySize(display);
} else {
final Point point = new Point();
point.x = display.getWidth();
point.y = display.getHeight();
return point;
}
}
private static class APIv11 {
private static Point getDisplaySize(Display display) {
final Point point = new Point();
display.getSize(point);
return point;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment