I have been trying to figure out how to find the height and width of the screen in android. i have found a way to get it but I dont know how to call the getScreenWidth and getScreenHeight to put values into my int height and int width?
public class Player {
public int across;
public int upDown;
public static int getScreenWidth(Context c) {
DisplayMetrics dmetrics = new DisplayMetrics();
((Activity) c).getWindowManager().getDefaultDisplay()
.getMetrics(dmetrics);
return dmetrics.widthPixels;
}
// Get screen height
public static int getScreenHeight(Context c) {
DisplayMetrics dmetrics = new DisplayMetrics();
((Activity) c).getWindowManager().getDefaultDisplay()
.getMetrics(dmetrics);
return dmetrics.heightPixels;
}
public Player() {
int width = dmetrics.widthPixels;
int height = dmetrics.heightPixels;
int rectSide = 1000;
//across = startPosX;
//upDown = startPosY;
}
i am trying to get it by using int width = dmetric.widthPixels; but this obviously isnt the way to call the getScreenWidth. Im pretty bad at this stuff, so any help would be great.