完成旧活动并开始新活动,反之亦然 [英] Finish old activity and start a new one or vice versa

查看:18
本文介绍了完成旧活动并开始新活动,反之亦然的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道,我用两个代码片段得到了相同的结果

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

finish();
startActivity(newActivity);

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?

推荐答案

当您执行 startActivity() 时,所做的只是将您的意图发布到事件队列中.活动的实际启动在不久的将来异步发生.所以我看不出两者有什么大的区别.

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.

这篇关于完成旧活动并开始新活动,反之亦然的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆