javaandroidandroid-activityrecreate

Does a recreated activity remember the original intent started it?


While checking the documentation about using onSaveInstanceState, a question popped up.

Let's say I'm using an app with several activities and now I'm in a specific activity that got started by a previous one. The current activity accepts extra values from the previous one.

If I get a phone call and then navigate back to the activity, it's recreated. But will it remember the original intent of the previous activity that started it? will it be able to get the extra variables from it after recreating itself?

To simplify things:

Activity A starts Activity B (and passing extras to it). Then (while in B) there's an incoming call. I go back to the app so B is recreated- will I still be able to get the extras passed from original the original activity A ?


Solution

  • Yes it will.

    One simple way to test this is to rotate the screen when the receiving activity is running, it will be will be destroyed and recreated, and you will notice that you can still get the extras.

    Try it and see by your own.