FLAG_ACTIVITY_CLEAR_TOP and onActivityResult

My activity stack is ABC, and C is on top. Started B using startActivityForResult ().

Now, in C, it launches A and clears the top using the following code:

finish(); intent = new Intent(this, A.class); intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); startActivity(intent); 

My question is, will onActivityResult () be called after executing the code above? I expected this to happen because B crashes after C launches A and clears the top. But my test code showed that onActivityResult () in was not called. I'm confused. Can anyone help?

Thanks.

+8
android
source share
2 answers

In your code, you start a new operation A, from ACTIVITY C. This will not call onActivityResult. This is simply because a new activity A has been launched. onActivityResult () will only be called when u finishes () your Acitive B.

I hope someone will add more to the underders if this is not clear.

+3
source share

try setting the startMode of your activity A to "singleTask" or use the FLAG_ACTIVITY_CLEAR_TOP flag along with FLAG_ACTIVITY_NEW_TASK. By default, ActivityA launchMode is standard, then a new instance of A will be created when A starts with C.

0
source share

All Articles