Android Get Size Display

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;
    }
This entry was posted in Android, Java. Bookmark the permalink.