Skip to content
This repository has been archived by the owner on Feb 26, 2023. It is now read-only.

Upgrading from 3.2 to 4.6.0 now all @Subscribe Method not working? #2259

Closed
imattaullah opened this issue Feb 2, 2020 · 6 comments
Closed

Comments

@imattaullah
Copy link

After 2 years i upgrade my code to android o now all @subscribe Method is not working?

AndroidAnnotations 4.6.0:

Android compile SDK 28:

import com.squareup.otto.Bus;

import org.androidannotations.annotations.EBean;
import org.androidannotations.annotations.UiThread;

@EBean(scope = EBean.Scope.Singleton)
public class EventBus extends Bus {

    @Override
    @UiThread(propagation = UiThread.Propagation.REUSE)
    public void post(Object event) {
        super.post(event);
    }
}

in acitivity

 @Bean
    EventBus bus;

    @Override
    protected void onStart() {
        bus.register(this);
        super.onStart();
    }

usage

bus.post(new ShareVerseEvent(mSurah.getNo(), mViewPager.getCurrentItem() + 1));

and

    @Subscribe
    public void onShareVerse(ShareVerseEvent event) {
        if (event.surahNo != surahNo || event.verseNo != verseNo || mverse == null)
            return;
       Log.e(">>>>", "MyMsg");
        AlertDialog dialog = new AlertDialog.Builder(getActivity())
                .setItems(names.toArray(new String[names.size()]), new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialog, int which) {
                    // my code
                    }
                })
                .create();
        dialog.show();
    }

and this


public class ShareVerseEvent {
    public final int verseNo;
    public final int surahNo;

    public ShareVerseEvent(int surahNo, int verseNo) {
        this.verseNo = verseNo;
        this.surahNo = surahNo;
    }
}

any method of @subscribe is not working why???

@WonderCsabo
Copy link
Member

WonderCsabo commented Feb 2, 2020

Have you followed the migration guide? You have to add another dependency. Please see here. https://github.com/androidannotations/androidannotations/wiki/4.0.0-migration-guide

@imattaullah
Copy link
Author

Have you followed the migration guide? You have to add another dependency. Please see here. https://github.com/androidannotations/androidannotations/wiki/4.0.0-migration-guide

i did not find any @subscribe method in migration link

@WonderCsabo
Copy link
Member

You can find Otto there.

@imattaullah
Copy link
Author

You can find Otto there.

Yes dear you see my code above I used the same as the following guide, but still @subscribe method not working. even in android show method never used.

@WonderCsabo
Copy link
Member

WonderCsabo commented Feb 2, 2020

Did you add this dependency to you build.gradle file?

annotationProcessor "org.androidannotations:otto:4.6.0"

@imattaullah
Copy link
Author

Did you add this dependency to you build.gradle file?

annotationProcessor "org.androidannotations:otto:4.6.0"

No! I forgot to add annotationProcessor "org.androidannotations:otto:4.6.0" now its working thanks @WonderCsabo

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants