Home  >  Q&A  >  body text

android - EventBus注销是在传值的页面注销还是接收值的页面注销?

很久没有用了 发现 不知道在哪个页面注销了

怪我咯怪我咯2764 days ago813

reply all(3)I'll reply

  • 天蓬老师

    天蓬老师2017-04-18 09:20:04

    1. The official DEMO is onResume()注册和onPause()anti-registration. However, this mechanism may not be suitable for most demand scenarios.

    2. If you are considering de-registering in onCreate(...)注册和onDestroy(), there is a situation you need to pay attention to:

    If an Activity creates multiple instances, and the Event from EventBus.post(Event) should only be received by the top-level Activity instance, then this will cause problems.

    reply
    0
  • PHP中文网

    PHP中文网2017-04-18 09:20:04

    Register in OnCreat and check whether you have registered before. Repeated registration will result in an error.

    Deregister in Destory. I have unregistered it in onPause, and when the page is not visible, the refresh broadcast or other broadcasts sent out cannot be received. After receiving the instance in the top-level Activity, you can also respond by writing OnEvent directly in the View, so before registering, check whether it has been registered. Just use this inside, not Context.

    reply
    0
  • 天蓬老师

    天蓬老师2017-04-18 09:20:04

    Who registers and who logs out? Register and unregister are the most scientific in the same category

    reply
    0
  • Cancelreply