is it necessary to set Fragment interface listeners to null on detach?

后端 未结 4 1225
感动是毒
感动是毒 2021-01-11 18:50

In Fragment examples involving callbacks, usually they assign the listener in the onAttach method and then set the listener to null in the onDetach method.

Is this l

4条回答
  •  难免孤独
    2021-01-11 19:11

    It's better to null the listener because you don't know when the garbage collector will destroy it. It's not really necessary to do this but it's good coding style.

提交回复
热议问题