Android Get Size Display

November 25, 2018 6:01 pm Published by

Un funzionalità per individuare la dimensione in pixel dello schemo di un device Android.

    private String getDisplaySize() {
    	
    	String result = "";
    	
        int int_width = 0;
        int int_height = 0;
    	
        Display display = getWindowManager().getDefaultDisplay();
        Point size = new Point();
 	
        if (android.os.Build.VERSION.SDK_INT < 13) {
        	int_width = display.getWidth();
        	int_height = display.getHeight();
        } else if (android.os.Build.VERSION.SDK_INT >= 13) {
        	int_width = size.x;
        	int_height = size.y;
        }
 
        result = result + "Width = " + Integer.toString(int_width) + "pixel \r\n";
        result = result + "Height = " + Integer.toString(int_height) + "pixel \r\n";
        
        return result;
    }

Categorised in: ,

This post was written by admin

Comments are closed here.