Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
257 views
in Technique[技术] by (71.8m points)

android - 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?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...