Android – Cannot reference executePendingTransactions from a static context… here is a solution to the problem.
Android – Cannot reference executePendingTransactions from a static context
I know the answer to that from this
If you want to immediately executing any such pending operations, you can call this function (only from the main thread) to do so.
However, if I call it from a static main thread, I get an error message stating that executePendingTransactions() is non-static and cannot be referenced from a static context.
How do I fix this?
Thanks!
Solution
executePendingTransactions()
is a regular, non-static method on FragmentManager
. You need an instance of FragmentManager, for example by calling getFragmentManager() (or getSupportFragmentManager()
, if you are in your activity
or
Use
fragments backport on Fragments.