Android - executePendingTransactions cannot be referenced from static context

I know from this answer that

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

But, if I call it from a static main thread, I get an error that says executePendingTransactions () is not static and cannot reference a static context.

How to fix it?

Thank!

+3


source to share


1 answer


executePendingTransactions()

- regular non-static method on FragmentManager

. You need an instance FragmentManager

, for example by calling getFragmentManager()

(or getSupportFragmentManager()

if you are using fragment backport) on Activity

or Fragment

.



+4


source







All Articles