BusProvider.getInstance().post(new QueueMessage(s));
BusProvider.getInstance().post(queue);
BusProvider.getInstance().post(weatherResponse);
但是我在MainActivity
@Subscribe
public void showOttoQueue(Queue queue) {
new NotificationStorege().setTicker("New message").setTitle("queue").setMessage("You are in the queue: "+queue.queue).generateNotification(this);
}
@Subscribe
public void showGcmMessage(GcmMessage message) {
Toast.makeText(this, "gcm message: " + message.Result, Toast.LENGTH_LONG).show();
}
@Subscribe
public void showOttoRemoveQueue(QueueMessage message) {
if (message.Result.equals("OK")){
new NotificationStorege().setTicker("New message").setTitle("queue").setMessage("you are out of queue").generateNotification(this);
Toast.makeText(this, "you are out of queue", Toast.LENGTH_LONG).show();
}else{
Toast.makeText(this, "error out of queue", Toast.LENGTH_LONG).show();
}
}
是否可以创建完整的类来存储所有这些方法?或者他们应该只在推出的活动中?
答案 0 :(得分:0)
您可以在所需的每个课程中自由使用Otto。只需注册该类的实例,如下面的代码。之后事件就会发生在那个对象上。
bus.register(classInstance);