Need help in determining if an android(G1) is an landscape mode or not? It would be great if someone could point me to some code snippets or a place in the online manual.
Nextstep


plusminus wrote:Probably not the best way, but a working one: (put this to onCreate of your Activity):Using java Syntax Highlighting
final Display defaultDisplay = getWindow().getWindowManager().getDefaultDisplay(); final int h= defaultDisplay.getHeight(); final int w = defaultDisplay.getWidth(); this.mIsLandScapeMode = (w > h); // LandscapeParsed in 0.033 seconds, using GeSHi 1.0.8.4
There is also a probably better method
Using java Syntax Highlighting
defaultDisplay.getOrientation()Parsed in 0.034 seconds, using GeSHi 1.0.8.4
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
Regards,
plusminus


Return to Code Snippets for Android
Users browsing this forum: No registered users and 3 guests