我只是好奇,我是否没有把这种在UI线程与否。根据该文件,在提交是UI线程上进一步在未来运行,当它有时间这样做。如果是这样的话,我可以在另一个线程上运行 FragmentTransactionmit()
I'm just curious about whether or not I have to call this on the UI-Thread or not. According to the documentation, the commit is run on the UI-thread further on in the future, when it has time to do so. If this is the case, can I run FragmentTransactionmit() on another thread?
推荐答案不完全明白你的意思。你可能总是有它发送一个消息给UI线程调用FragmentTransactionmit()。任何其他线程
Not exactly sure what you mean. You may always have any other thread which sends a message to the UI thread invoking FragmentTransactionmit().
不过,我不明白为什么你不请立即提交的所有事务之后。
However, I do not quite understand why you do not call commit immediately after all the transactions.
我甚至会想到,你甚至可以体验空指针错误应该有过任何改变的片段或者其取决于数据 - 这会导致您的应用程序的不同的状态时相比,你会打电话立即提交 - 我的意思是在延迟期间。
I would even expect that you may even experience NullPointer Errors should there have been any changed to the fragments or their depending data - during the delay I mean - which cause a different state of your app than when you would call commit immediately.
此外,在这种情况下,你应该叫 fragmentManager.executePendingTransactions(),以确保所有的更改将作出,否则你可能会认为交易已经发生 - 这其实他们还没有。
Also in that context you should call fragmentManager.executePendingTransactions() to ensure that all your changes will be made, otherwise you may assume that the transactions have taken place - which in fact they haven't yet.
更多推荐
是Android FragmentTransaction.commit()方法线程安全吗?
发布评论