Which Activity lifecycle methods are best to register/unregister to event bus?

后端 未结 4 1276
迷失自我
迷失自我 2021-02-07 00:00

What is the best place to register and unregister to an event bus (like otto, EventBus, or tinybus) in an Activity and why?

  1. onCre
4条回答
  •  滥情空心
    2021-02-07 00:27

    First of all, its not a objective question rather its a subjective one and will draw lots of arguments based on arguments.

    From my experience, We used Otto in one of our project. We followed onResume()-onPause() which served us very good. It also makes sense cause we should register as late as possible & deregister as fast as possible while using an event bus.

提交回复
热议问题