Get screen resolution as integer on Android

// In order to work, this snippet requires at least Android SDK API 13 + // Inside an working activity Display display = getWindowManager().getDefaultDisplay(); Point size = new Point(); display.getSize(size); int width = size.x; int height = size.y; // Anywhere: WindowManager wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE); Display display = wm.getDefaultDisplay(); Point size = new Point(); display.getSize(size); int width = size.x; int height = size.y; // If in Android SKD's API 13 or below use these deprecated calls: Display display = getWindowManager().getDefaultDisplay(); int width = display.getWidth(); int height = display.getHeight();
Simple snippet showing different ways to get the device's screen resolution on Android.

#WindowManager #Display #Point
#screen #resolution #android

#cesarnog

Be the first to comment

You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.