android - EventBus注销是在传值的页面注销还是接收值的页面注销?
怪我咯
怪我咯 2017-04-18 09:18:04
0
3
774

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

怪我咯
怪我咯

走同样的路,发现不同的人生

reply all (3)
Peter_Zhu
  1. The official DEMO isonResume()注册和onPause()anti-registration. However, this mechanism may not be suitable for most demand scenarios.

  2. If you are considering de-registering inonCreate(...)注册和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.

    洪涛

    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.

      Peter_Zhu

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

        Latest Downloads
        More>
        Web Effects
        Website Source Code
        Website Materials
        Front End Template
        About us Disclaimer Sitemap
        php.cn:Public welfare online PHP training,Help PHP learners grow quickly!