Last active
September 9, 2016 04:35
-
-
Save dmpatel151282/e038f101b7f8faa47c8fdb6a48d6aa35 to your computer and use it in GitHub Desktop.
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
There are generally three ways to do this: | |
1. As some of the answers suggested, you could distinguish the cases of your activity being created for the first time and being restored from savedInstanceState. | |
This is done by overriding onSaveInstanceState and checking the parameter of onCreate. | |
2. You could lock the activity in one orientation by adding android:screenOrientation="portrait" (or "landscape") to <activity> in your manifest. | |
<activity android:screenOrientation="landscape"> | |
3. You could tell the system that you meant to handle screen changes for yourself by specifying android:configChanges="screenOrientation" in the <activity> tag. | |
This way the activity will not be recreated, but will receive a callback instead (which you can ignore as it's not useful for you). | |
<activity | |
android:name=".YourActivityName" | |
android:configChanges="orientation|screenSize"> | |
</activity> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment