Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android - executePendingTransactions cannot be referenced from static context

I know from this answer that

If you want to immediately executing any such pending operations, you can call this function (only from the main thread) to do so.

But, if I call it from the static main thread, I get an error that says executePendingTransactions() is non-static and cannot be referenced from static context.

How do I fix this?

Thank you!

like image 309
AndroidWizard Avatar asked May 13 '26 23:05

AndroidWizard


1 Answers

executePendingTransactions() is a regular non-static method on FragmentManager. You need an instance of FragmentManager, such as by calling getFragmentManager() (or getSupportFragmentManager() if you are using the fragments backport) on your Activity or Fragment.

like image 133
CommonsWare Avatar answered May 16 '26 12:05

CommonsWare



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!