You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Apr 30, 2019. It is now read-only.
i have a problem when send event from activity (with post/produce) to a fragment. the event will be taken from binded service if the activity recevied notification via brodcast receiver when the service received a message.
Activity{
private SMS sms;
... @OverRide
protected void onCreate(@nullable Bundle savedInstanceState) {
...
smsFragment = new TransactionSMSFragment();
getSupportFragmentManager().beginTransaction().add(R.id.stack_container, smsFragment, RegisterServerListFragment.TAG).commit();
}
From EventBus.getInstance().post(sms); it seems to me that you're mixing Otto with Greenrobot's EventBus. @Produce annotation is only provided by Otto. If you want to use Otto you can do like this:
publicclassOttoBus {
privatestaticBusbus;
publicstaticBusgetInstance(){
if (bus == null)
bus = newBus();
returnbus;
}
}
and later OttoBus.getInstance().post(sms);.
Sign up for freeto subscribe to this conversation on GitHub.
Already have an account?
Sign in.
i have a problem when send event from activity (with post/produce) to a fragment. the event will be taken from binded service if the activity recevied notification via brodcast receiver when the service received a message.
Activity{
private SMS sms;
...
@OverRide
protected void onCreate(@nullable Bundle savedInstanceState) {
...
smsFragment = new TransactionSMSFragment();
getSupportFragmentManager().beginTransaction().add(R.id.stack_container, smsFragment, RegisterServerListFragment.TAG).commit();
}
private BroadcastReceiver smsReceiver = new BroadcastReceiver() {
....
@OverRide
public void onReceive(Context context, Intent intent) {
if(DEBUG)Log.i(TAG, "sms>reciver");
if(intent != null){
SMS sms = smsService.getReceivedMessege();
this.sms = sms;
EventBus.getInstance().post(sms);
}
}
};
@produce
public String produce(){
return this.sms;
}
Fragment{
...
@subscribe
public void subscribeSMS(SMS sms){
Log.d("bus", "sms:" + sms );
}
}
what wrong with those code ? how actually otto work ? thank's
The text was updated successfully, but these errors were encountered: