User Code List
All my code
---Android
------Sending SMS using Intents
------Send email attachment
------read file from sdcard
------get size of screen
------Accelerometer in Android OS 2.x and deprecated API
------Getting Animation Drawables to actually Animate
------hide the status bar and title bar
------Email, send intent
------wifi scanner
---------New Snippet
------scrollable tabhost
------bluring windows when dialog shows up
------Animated activity transition, diagonal slide
------simple way to scale image
------monitor outgoing phone call
------add directory in sdcard
------EditTextPreference only numbers
------MapView, LongPress, GestureDetector, OnTouchListener
------Preference Screen with custom views
------write and read data from file
------background without stretching
------System setting, change and write_settings
------Creating Persistent AlertDialog for on Orientation Change
------print from Android application
------Screen in landscape mode
------add contact photo to your list
------Distance calculation between 2 Geopoint by Haversine formula
---Iphone
------get iphone orientation
------generate pdf from iphone
------new thread autorelease pool
------determine firmware version
------turn page animation
------load resource file to webview
------call javascript in Objective-C code
------call objective-C code from Javascript
------Disable Webview selection flash
------Disable the action popup
------Disable webview zoom effect
---Utilities
------recursive remove .svn directory
New Snippet
 
 
Screen in landscape mode
 

Probably not the best way, but a working one: (put this to onCreate of your Activity):

Java:

final Display defaultDisplay = getWindow().getWindowManager().getDefaultDisplay();

final int h= defaultDisplay.getHeight();

final int w = defaultDisplay.getWidth();

this.mIsLandScapeMode = (w > h); // Landscape

There is also a probably better method Arrow Down

Java:

defaultDisplay.getOrientation()

int SCREEN_ORIENTATION_BEHIND Constant corresponding to behind in the screenOrientation attribute. 3

int SCREEN_ORIENTATION_LANDSCAPE Constant corresponding to landscape in the screenOrientation attribute. 0

int SCREEN_ORIENTATION_NOSENSOR Constant corresponding to sensor in the screenOrientation attribute. 5

int SCREEN_ORIENTATION_PORTRAIT Constant corresponding to portrait in the screenOrientation attribute. 1

int SCREEN_ORIENTATION_SENSOR Constant corresponding to sensor in the screenOrientation attribute. 4

int SCREEN_ORIENTATION_UNSPECIFIED Constant corresponding to unspecified in the screenOrientation attribute. -1

int SCREEN_ORIENTATION_USER Constant corresponding to user in the screenOrientation attribute. 2 0x00000002

 
Sub-Article List