是否始终需要executePendingTransactions()? [英] Is executePendingTransactions() always necessary?

查看:146
本文介绍了是否始终需要executePendingTransactions()?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这更多是一个理论问题.

This is more of a theoretical question.

我遇到这样的情况,我的应用程序在调用 executePendingTransactions()进行片段交换时崩溃,并且没有它也可以正常工作.

I have a situation where my app crashes on a fragment swap with an executePendingTransactions() call and works fine without it.

我的问题是,如果我不致电 executePendingTransactions(),通常会出什么问题?

My question is what could go wrong in general if i don't call executePendingTransactions()?

据我了解,如果没有这种方法,尽管我从未经历过,但 Fragment 交换可能不会立即发生.

As i understand, without this method a Fragment swap may not happen immediately, although i have never experienced this.

推荐答案

除非您要执行依赖于事务的操作,否则不需要这样做.来自 API文档

It's not required unless you are executing something that depends on the transaction. From the API documentation,

使用 FragmentTransaction 提交后 FragmentTransaction.commit(),计划执行在进程的主线程上异步.如果你想立即执行任何此类待处理操作,您可以将其称为函数(仅来自主线程)来执行此操作.请注意,所有回调并且其他相关行为将在此调用内完成,因此小心从哪里调用.

After a FragmentTransaction is 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.

这篇关于是否始终需要executePendingTransactions()?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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