New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
GreenRobot: EventBus's isRegistered() method not working as expected #355
Comments
Are you sure that If your MainActivity is being destroyed and recreated (eg due to rotation) then it will be a different instance each time. Also, when/where are you registering? |
Instance is different everytime as I am destroying the Activity and creating it everytime and registering it but why I am getting mutliple logs though instance is different? If Activity 1 is destroyed and and I open it again say Activity 2 then why it is sending me the event registered with Activity 1? |
Because if you never unregistered Activity1 then EVentBus still has a reference to it, so will still send it messages. You should ALWAYS unregister your subscriber at the equivalent exit point. |
ok, got it thanks for the brief explanation! It would be good that you answer on StackOverflow as well to keep for future users - http://stackoverflow.com/questions/39589046/greenrobot-eventbuss-isregistered-method-not-working-as-expected |
I am using EventBus for receiving the events. I want to check if my Activity is already registered or not as I need to register only once through the whole lifetime of the application, but the issue is that wheneven I come to that Activity which is registered EventBus registers it again and due to that multiple events are getting fired.
Below is my code sample!
Also, find the screenshot of logs, in which you can see that initially it gives me proper response but once I move to that Activity again it registers the subscriber again!
NOTE: Please don't suggest me to unregister as I want it to be registered always!
The text was updated successfully, but these errors were encountered: