android-screen
How to get android device screen size?
try this code to get screen size in inch DisplayMetrics dm = new DisplayMetrics(); getWindowManager().getDefaultDisplay().getMetrics(dm); int width=dm.widthPixels; int height=dm.heightPixels; double wi=(double)width/(double)dm.xdpi; double hi=(double)height/(double)dm.ydpi; double x = Math.pow(wi,2); double y = Math.pow(hi,2); double screenInches = Math.sqrt(x+y);
How do I get the ScreenSize programmatically in android
Copy and paste this code into your Activity and when it is executed it will Toast the device’s screen size category. int screenSize = getResources().getConfiguration().screenLayout & Configuration.SCREENLAYOUT_SIZE_MASK; String toastMsg; switch(screenSize) { case Configuration.SCREENLAYOUT_SIZE_LARGE: toastMsg = “Large screen”; break; case Configuration.SCREENLAYOUT_SIZE_NORMAL: toastMsg = “Normal screen”; break; case Configuration.SCREENLAYOUT_SIZE_SMALL: toastMsg = “Small screen”; break; default: toastMsg = … Read more
Lock Android phone application to Portrait mode
Yes. Add android:screenOrientation=”portrait” to the manifest under your main activity. <activity android:name=”.yourActivity” android:screenOrientation=”portrait”… />