AndroidEventBus icon indicating copy to clipboard operation
AndroidEventBus copied to clipboard

hello,I discovered a problem,the function that eventbus.getdefault.postSticky() in BroadcastReceiver is not work,please help me,thank you

Open ApeForProgram opened this issue 9 years ago • 2 comments

hello,I discovered a problem,the function that eventbus.getdefault.postSticky() in BroadcastReceiver is not work,please help me,thank you

ApeForProgram avatar Mar 30 '16 02:03 ApeForProgram

is your BroadcastReceiver run in other process ?

hehonghui avatar Mar 31 '16 04:03 hehonghui

I solved the problem,but the other one is coming,at the same activity,I call functions include EventBus().getDefault().registerSticky(this) and EventBus.getDefault.postSticky(msg) ,the function noted by @Subscriber will work,ok or not ? The msg I post is a java bean, this is the java bean: public class PWDEventBusMsg implements Serializable{ public boolean b ; public String detail;

public PWDEventBusMsg(boolean b, String detail){
    this.b = b;
    this.detail = detail;
}

public String getDetail(){
    return getDetail();
}

public boolean getMsg(){
    return b;
}

}

And the ide prints logs are:

04-07 15:50:05.388 26364-26364/com.lhwh.lehuaonego W/System.err: at com.lhwh.lehuaonego.bean.PWDEventBusMsg.getDetail(PWDEventBusMsg.java:18)

04-07 15:50:05.388 26364-26364/com.lhwh.lehuaonego W/System.err: at com.lhwh.lehuaonego.activity.ForgetPosswordActivity.onEventMainThread(ForgetPosswordActivity.java:272)

the function noted by @Subscriber : @Subscriber public void onEventMainThread(PWDEventBusMsg msg) { if (msg.getMsg()) { initRequest(); } else { MyToast.show(getApplicationContext(), msg.getDetail()); } }

The corresponding codes are:

line 18: At class named PWDEventBusMsg , return getDetail();

line 272: At the function noted by @Subscriber ,
MyToast.show(getApplicationContext(), msg.getDetail());

Thanks

ApeForProgram avatar Apr 07 '16 08:04 ApeForProgram