我使用 FragmentDialog 订阅使用 otto 库的事件。
@Subscribe
public void onPickupRequestResponse (PassengerPickupRequestResponseEvent event){
Toast.makeText(this.getActivity().getApplicationContext(), "Event handled", Toast.LENGTH_SHORT).show();
dismiss();
}
我在 OnResume 事件中注册 FragmentDialog 并在 onPause 方法中取消注册。
@Override
public void onResume() {
super.onResume();
App.bus.register(this);
}
@Override
public void onPause() {
super.onPause();
App.bus.unregister(this);
}
然后在活动中我发布活动
App.bus.post(new PassengerPickupRequestResponseEvent());
但我的 FragmentDialog 不处理此事件。