I am getting this warning and the code written in my event subscriber is not triggered always.. it is very random.
Can someone help me with this. Thanks.
I have this class which posts the event...
EventListAdapter
:
protected void updateDbToHandle(Context context, Cursor cursor) {
//something here....
toggleEvent.setContext(context);
EventBus.getDefault().post(toggleEvent);
}
protected void updateDbToIgnore(Context context, Cursor cursor) {
//something here....
toggleEvent.setContext(context);
EventBus.getDefault().post(toggleEvent);
}
Event class
:
public class ToggleEvent {
private String name;
private Context context;
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public Context getContext() {
return context;
}
public void setContext(Context context) {
this.context = context;
}
}
and the subscriber
:
public class ToggleEventListener {
public ToggleEventListener() {
super();
EventBus.getDefault().register(this);
}
public void onEvent(ToggleEvent toggleEvent) {
Log.d("toggleEvent", "toggle event triggered in event bus");
Context context = toggleEvent.getContext();
Intent intentForRinger = new Intent(context, RingerToggler.class);
System.out.println("change in calendar is here ");
//calRead.getEventControl(context);
intentForRinger.putExtra("START_TIME", false);
intentForRinger.putExtra("RESCAN", false);
intentForRinger.putExtra("CHANGE", true);
intentForRinger.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startService(intentForRinger);
EventBus.getDefault().unregister(this);
}
}
Not sure why I get this warning...
and also my code written inside the toggle event is not executed everytime..
it is getting missed and it is very random that the event is invoked...