Get Set Screen Orientation Android Code

// in AndroidManifest.xml
<Activity
 android:screenOrientation="portrait" // or landscape
 
// in MyActivity.java
boolean mbOrientacionLandscape = false;
int nOrientation =	getResources().getConfiguration().orientation;
if(mbOrientacionLandscape==true){
	 getResources().getConfiguration();
	if(nOrientation != Configuration.ORIENTATION_LANDSCAPE)
	setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
 
}
else{
	if(nOrientation != Configuration.ORIENTATION_PORTRAIT)
	setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
}
This entry was posted in Android Examples Code and tagged . Bookmark the permalink.


Comments are closed.



2,915 views