Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

FLAG_ACTIVITY_CLEAR_TOP and onActivityResult

Tags:

android

My activity stack is A B C, with C at the top. A started B using startActivityForResult().

Now, in C, it starts 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() in A be called after the code above is executed? I expected it will, because B is destroyed after C starts A and clears the top. But, my test code showed that onActivityResult() in A was not called. I am confused. Can someone help?

Thanks.

like image 816
Kai Avatar asked Feb 11 '11 17:02

Kai


1 Answers

In your code you are starting a new Activity A, from ACTIVITY C. This will not call the onActivityResult. This simply because a new Activity A is started. onActivityResult() will be called only when u finish() your Acitivity B.

I hope someone adds more to the anwsers, if this doesn make it clear.

like image 143
Varun Avatar answered Nov 14 '22 05:11

Varun