0

I'm getting this error: java.lang.NoSuchMethodError: android.view.Display.getSize

How can I fix this?

This is my code:

Point p = new Point();
this.getWindowManager().getDefaultDisplay().getSize(p);
int screenWidth = p.x;
int screenHeight = p.y;
Jonan
  • 2,485
  • 3
  • 24
  • 42

2 Answers2

0

getSize() method was added in API level 13. May be you are running your app on device with lower version than 13. Can you please validate this.

Sunny Garg
  • 1,073
  • 1
  • 6
  • 13
0

if you develop for API 12 or lower:

int screenWidth = this.getWindowManager().getDefaultDisplay().getWidth;
int screenHeight = this.getWindowManager().getDefaultDisplay().getHeight;

if you develop for api 13 or higher Maybe you should install the right SDK (in eclipse Windows > Android SDK Manager)

user3432681
  • 564
  • 4
  • 10
  • 25