This code snippet will make you know when the user changes the Orientation of the application screen.
This code will make the orientation fix the activity to Landscape
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<activity | |
android:name=".MyActivity" | |
android:label="@string/app_name" | |
android:configChanges="orientation|screenSize"> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Override | |
public void onConfigurationChanged(Configuration newConfig) { | |
super.onConfigurationChanged(newConfig); | |
if(newConfig.orientation==Configuration.ORIENTATION_LANDSCAPE){ | |
Log.d("SOMU","Orientation Changed to Landscape mode"); | |
} | |
else if(newConfig.orientation==Configuration.ORIENTATION_PORTRAIT){ | |
Log.d("SOMU","Orientation Changed to Potrait mode"); | |
} | |
} |
This code will make the orientation fix the activity to Landscape
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<activity | |
android:name=".MyActivity" | |
android:label="@string/app_name" | |
android:screenOrientation="landscape"> |
No comments:
Post a Comment