Reputation: 143
I'm getting a "The method getHeight() from the type Display is deprecated" error when trying to get the Height and Width of the screen size, code:
public JumpboyView(MyView mv, Context contextPlay) {
super(contextPlay);
// TODO Auto-generated constructor stub
bBoy = BitmapFactory.decodeResource(getResources(), R.drawable.boy);
Display display = ((WindowManager) contextPlay.getSystemService(Context.WINDOW_SERVICE)).getDefaultDisplay();
height = display.getHeight();
and when trying to use getWindowManager().getDefaultDisplay().getMetrics(displaymetrics);
I get "The method getWindowManager() is undefined for the type JumpboyView" with 2 fixes available change to getWindowToken() or create method..
Help please?
p.s it used to work on older versions :\
Upvotes: 2
Views: 1173
Reputation: 18670
Try this:
Display display = ((WindowManager) contextPlay.getSystemService(Context.WINDOW_SERVICE)).getDefaultDisplay();
Point size = new Point();
display.getSize(size);
height = size.y
Upvotes: 2