EventBus
EventBus copied to clipboard
EventBus.getDefault (). Isregistered (this) method is invalid
Eventbus.getdefault ().isregistered (this) returns false when plug-in APK (loaded by classLoader) USES eventbus.getdefault ().isregistered (this) to determine if EventBus isregistered, even if I have registered previously.
Have a look at the source code what might be the issue. You might also provide an example project reproducing this.
` public void register(Object subscriber) { if (AndroidDependenciesDetector.isAndroidSDKAvailable() && !AndroidDependenciesDetector.areAndroidComponentsAvailable()) { // Crash if the user (developer) has not imported the Android compatibility library. throw new RuntimeException("It looks like you are using EventBus on Android, " + "make sure to add the "eventbus" Android library to your dependencies."); }
Class<?> subscriberClass = subscriber.getClass();
List<SubscriberMethod> subscriberMethods = subscriberMethodFinder.findSubscriberMethods(subscriberClass);
Collections.sort(subscriberMethods);
synchronized (this) {
for (SubscriberMethod subscriberMethod : subscriberMethods) {
subscribe(subscriber, subscriberMethod);
}
}
}`
look at this code,maybe it 's because there 's no @subscribe method in your registered class.so it won't execute the subscribe method
The original poster has not replied in a long time. Closing this.