This is similar to the noob question, but in Android, when the orientation changes activity, it is destroyed and recreated, and the onCreate () function is called again. The internal state can be saved through the savedInstanceState package. So far so good.
But in my application, I have an activity that is usually called from another action via startActivityForResult (), which is passed to a bunch of parameters. In onCreate (), the target activity does getIntent () to retrieve the transferred data. The problem is that when this action is displayed on the screen and I flip the orientation with which it falls. It crashes in onCreate () code, where it calls getIntent (). I assume that it crashes because there is nothing to “get”, because in this case it is called from the system and not from another activity.
What is the right way to handle this? How do I know when my onCreate () is called due to a change in orientation, so I'm not trying to call getIntent ()? Or am I just thinking about it wrong? Thank you in advance.
user316117
source share