1

Say I have a Fragment and I have posted on UI handler from background thread, a runnable to modify Fragment before onDestroyView of Fragment was called.

Is the posted runnable guaranteed to be called before onDestroyView will be called or can onDestroyView be called before the runnable has a chance to execute?

q126y
  • 1,589
  • 4
  • 18
  • 50

1 Answers1

0

If the handler is on a background thread, then it is not guaranteed to complete before onDestroyView is called. If you need the logic to run before onDestroyView, it is best to call it in the fragment's onStop() method.

mustaccio
  • 18,234
  • 16
  • 48
  • 57
Brian Acker
  • 323
  • 3
  • 10