Android: How to get the real screen size of the device?

Try calling

    display.getRealSize();

DISCLAIMER: I did not realize this, but this will only work for API 17 (Android 4.2/JellyBean) and up.


Try this

 final DisplayMetrics metrics = new DisplayMetrics(); 
    Display display = getWindowManager().getDefaultDisplay();     
    Method mGetRawH = null,mGetRawW = null;

try {

    // For JellyBeans and onward
    if(android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.JELLY_BEAN){

        display.getRealMetrics(metrics);
        realWidth = metrics.widthPixels;
        realHeight = metrics.heightPixels;
    }
    else{
    // Below Jellybeans you can use reflection method 

        mGetRawH = Display.class.getMethod("getRawHeight");
        mGetRawW = Display.class.getMethod("getRawWidth");

        try {
            realWidth = (Integer) mGetRawW.invoke(display);
            realHeight = (Integer) mGetRawH.invoke(display);
        } catch (IllegalArgumentException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        } catch (IllegalAccessException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        } catch (InvocationTargetException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
    }