There are a lot of discussions on this but quite frankly they are all pretty advanced and as a newbie to Android development I can't make this work.
I simply need nothing to change when the screen is rotated. My app displays a random image when it first loads and rotating the device should not select another random image.
How can I (simply) make this behavior stop?
There are generally three ways to do this:
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
You could lock the activity in one orientation by adding
<activity> in your manifest.
You could tell the system that you meant to handle screen changes for yourself by specifying
android:configChanges="orientation|screenSize" 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).
Personally I'd go with (3). Of course if locking the app to one of the orientations is fine with you, you can also go with (2).