I have a small class that needs to keep track of the devices width and height.
public class BrScreenMetrics {
public static int screenX=0;
public static int screenY=0;
public static void setMetrics(Activity activity)
{
WindowManager w = activity.getWindowManager();
Display d = w.getDefaultDisplay();
screenX = d.getWidth();
screenY = d.getHeight();
}
}
With each new activity i unvoke the line:
BrScreenMetrics.setMetrics(this);
which updates the values on rotation etc… This works great, except that it is returning 320×522, not my desire’s 480×800.
What am i doing wrong?
Slight Update:
I tried it with this code as well using androids own metrics class:
public static void setMetrics(Activity activity)
{
DisplayMetrics metrics = new DisplayMetrics();
activity.getWindowManager().getDefaultDisplay().getMetrics(metrics);
screenX = metrics.widthPixels;
screenY = metrics.heightPixels;
}
but it is still 320×522 🙁
Thanks looking into the manifest was indeed the right way, I found out in the end i needed
with a minimum requirement of 4-6.
Here is my utility if anyone finds it useful or can offer ways to make it better: