微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

android – executePendingTransactions()总是必要的吗?

这更像是一个理论问题.

我有一种情况,我的应用程序崩溃与片段交换与executePendingTransactions()调用,并没有它工作正常.

我的问题是,如果我不调用executePendingTransactions(),一般会出现什么问题?

据我所知,没有这种方法,片段交换可能不会立即发生,虽然我从未经历过这种情况.

解决方法

除非您执行的操作取决于事务,否则不需要它.从 API documentation,

After aFragmentTransactionis committed with
FragmentTransaction.commit(),it is scheduled to be executed asynchronously on the process’s main thread. If you want to immediately executing any such pending operations,you can call this function (only from the main thread) to do so. Note that all callbacks and other related behavior will be done from within this call,so be careful about where this is called from.

原文地址:https://www.jb51.cc/android/315538.html

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐