android - @Subscribe 方法为同一事件调用多次

标签 android otto

在我的代码中,我正在使用 @Subscribe 注释来监听事件:

@Subscribe
public void orderUpdate(OrderUpdateEvent event)

我的问题是,对于同一个事件对象,此方法被多次调用(1-3 次取决于每次运行)。

这就是我发送此事件的方式:

busProvider.getEventBus().postOnMain(new OrderUpdateEvent();

这可能是什么原因?我是否遗漏了什么?

最佳答案

What could be the cause of that?

一种可能性是您仍然在事件总线上注册了此类的三个实例。确保您在对象不应再接收消息时unregister()

关于android - @Subscribe 方法为同一事件调用多次,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28015580/

相关文章:

android - Android涂抹布局

android - 事件总线 : How to keep track?

android - 方形奥托 : @Subscribe is not called in fragment (Android)

android - 从广播事件切换到奥托有什么好处

java - Android - findViewById(int id) 始终返回 null

Android SDK 和 AVD 管理器问题

java - 使用 uinput 驱动程序创建虚拟多点触控设备

android - 应定义“名称”属性 - android list 中的错误

java - WebViewClient.shouldOverrideUrlLoading 中的 FragmentTransaction 抛出 IllegalStateException

android - 使用 Intent 或事件总线在同一个应用程序中进行通信