Back to project page android.widget.
The source code is released under:
Apache License
If you think the Android project android.widget listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
package me.dm7.android.widget; /* ww w . j ava 2 s . c o m*/ import android.content.Context; import android.content.res.Configuration; import android.graphics.Point; import android.view.Display; import android.view.WindowManager; public class DisplayUtils { public static Point getScreenResolution(Context context) { WindowManager wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE); Display display = wm.getDefaultDisplay(); Point screenResolution = new Point(); if (android.os.Build.VERSION.SDK_INT >= 13) { display.getSize(screenResolution); } else { screenResolution.set(display.getWidth(), display.getHeight()); } return screenResolution; } public static int getScreenOrientation(Context context) { WindowManager wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE); Display display = wm.getDefaultDisplay(); int orientation = Configuration.ORIENTATION_UNDEFINED; if(display.getWidth()==display.getHeight()){ orientation = Configuration.ORIENTATION_SQUARE; } else{ if(display.getWidth() < display.getHeight()){ orientation = Configuration.ORIENTATION_PORTRAIT; }else { orientation = Configuration.ORIENTATION_LANDSCAPE; } } return orientation; } }