Code example for Display

Methods: getSize

0
		Display display = wm.getDefaultDisplay();
 
		if (Build.VERSION.SDK_INT<=16){ // Android 4.0 and lowers
			if (Build.VERSION.SDK_INT>13){
				Point size = new Point();
				display.getSize(size);
				results.put("Screen width", String.valueOf(size.x));
				results.put("Screen height", String.valueOf(size.y));
			} else { 
				try { 
					Method mGetRawH = Display.class.getMethod("getRawHeight");
					Method mGetRawW = Display.class.getMethod("getRawWidth");
					results.put("Screen width",String.valueOf((Integer) mGetRawW.invoke(display)));
					results.put("Screen height", String.valueOf((Integer) mGetRawH.invoke(display)));
				} catch (Exception e) {
					Log.d("Error", "\n Error accessing to video data.");
					results.put("Screen width", "UNKNOWN");
					results.put("Screen height", "UNKNOWN");
				} 
			} 
		} else { // Android 4.1 or highers