Android examples for android.view:Display
Get display Size
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 w ww . j ava2s . 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(); } } }