My code to get the screen height dynamically:
Display display = ((Activity) getContext()).getWindowManager().getDefaultDisplay();
Point size = new Point();
display.getSize(size);
int width = size.x;
int height = size.y;
Error:
Error: java.lang.ClassCastException: android.app.Application
Complete log cat: http://pastebin.com/8zUNFUYn
Edit:
Changed code to this:
Display display = (activity).getWindowManager().getDefaultDisplay();
Point size = new Point();
display.getSize(size);
int width = size.x;
int height = size.y;
Worked but, gave a new error that is display.getSize(size) is not a method. Is that API depreceated?
is base class for both Application and Activity. Since your a getting an Application with
getContext(), casting it toActivitycauses theClassCastExecption.