Search code examples
androidandroid-activity

Finish old activity and start a new one or vice versa


I know, that I get the same result with both code snippets

finish();
startActivity(newActivity);

and

startActivity(newActivity);
finish();

I'd like to know your opinion, if there is a big difference between them. Is one better than the other? If so, why?


Solution

  • When you do startActivity(), all that does is post your intent in a queue of events. The actual starting of the activity happens asynchronously in the near future. So I don't see a big difference between the two.