Android Intent Movement, Activity Life Cycle Question!

Asked 2 years ago, Updated 2 years ago, 20 views

After performing the activities A, B, C, D, and E in order, move the int from E to B and do "FLAG_ACTIVITY_CLEAR_TOP" In that case, the remaining activities It should be A and B, but is it correct that the method running on B is changed from onStop() state to onStart() after onRestart() state?

Then, I wonder if onCreate() is running instead of onStart() of C activity when you run the next C activity!

android

2022-09-21 19:04

1 Answers

If you call B from the stack of A > B > C > D > E using the properties of FLAG_ACTIVITY_CLEAR_TOP, it will be removed in the order of E, D, and C, and B will be restarted from onCreate().

As you said, if you want to run it in the order of onRestart() > onStart() > onResume(), you must also use the properties of FLAG_ACTIVITY_SINGLE_TOP as shown in the code below.

intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
intent.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);


2022-09-21 19:04

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.