Issue
I want to start my MainActivity with a new Intent in my other Activity. The two Activities are in the same app, and the second Activity is actually started from the MainActivity. So the scenario is like this:
- MainActivity is created with an Intent
- MainActivity starts SecondActivity (but MainActivity is not destroyed yet. It is just stopped)
- SecondActivity starts MainActivity with a new Intent (SecondActivity is not closed)
The MainActivity is not flagged. I mean, the Activity's launch mode in the manifest is not set (so, it's default).
I want to know what happens to MainActivity's lifecycle and intent.
Is the Activity re-created? Is onCreate() called? Then is onCreate() called twice, without onDestory()? Or the new MainActivity is newly created and there will be two MainActivities? Will the Intent from getIntent() overwritten?
I know Activity.onNewIntent() is called for singleTop Activities. Then in my situation onNewIntent() is not called?
Thanks in advance.
Solution
Is the Activity re-created? Is onCreate() called? Then is onCreate() called twice,
Yes, yes, and yes, because the default launchMode of an activity is "standard". Activity with standard launchmode will create a new instance how many times you want.
Will the Intent from getIntent() overwritten?
AFAIK, It's still the same Intent.
Answered By - Glenn
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.