Android examples for User Interface:Display
Set display Size vis reflection
//package com.java2s; import java.lang.reflect.Method; import android.graphics.Point; import android.view.Display; public class Main { public static void displaySize(Display display, Point outSize) { try {/*from ww w. ja v a2 s. c o m*/ // test for new method to trigger exception Class<?> pointClass; pointClass = Class.forName("android.graphics.Point"); Method newGetSize = Display.class.getMethod("getSize", new Class[] { pointClass }); // no exception, so new method is available, just use it newGetSize.invoke(display, outSize); } catch (Exception ex) { // new method is not available, use the old ones outSize.x = display.getWidth(); outSize.y = display.getHeight(); } } }