There’s stuff I’d like to do in my Activities’ onCreate() method only if they’re constructed the first time, not when the device was rotated (on configuration changes). Currently I’m checking the savedInstanceState parameter passed into onCreate() for this. If it’s null, then it’s the first time the Activity starts, else there was only a rotation.
Is this a good and reliable way to tell this? Are there alternatives to this?
I don’t know of a better solution. Romain Guy describes the same approach (checking savedInstance state or other objects you pass for null).
When I am lazy to do this, I just disable recreating the Activity on orientation change. As described at How do I disable orientation change on Android?