Search code examples
androidandroid-activityandroid-lifecycle

What happens after the activity is destroyed when finish() is invoked?


I have seen this post on the finish() keyword in android What is Activity.finish() method doing exactly?

..but it couldn't find anything that answered my question.

If finish() is called on an activity, will the next activity in the stack be invoked? What if we started that activity for a result from another activity--will onActivityResult() of that other activity be invoked rather than the next activity in the stack? What takes priority over another? I couldn't really find much on these kind of questions.

Thanks!


Solution

  • if you start ActivityB from ActivityA and if you call finish() from ActiivityB ,ActivityB will be removed from stack,ActivityA will be on top of stack.

    if you start ActivityB from onActivityResult() of ActivityA,when you finish ActivityB again ActivityA will be on top of stack.

    onActivityResult() will not be invoked because onActivityResult() in just method belongs to ActivityA . so stack is all about activity stack.