Tag: otto

调用startService()方法发送otto事件后如何知道服务何时启动?

我有AlarmReceiver( BrodcastReceiver )启动DownloadService( Service )后,检查服务是否运行状态 context.startDownloadServiceIfNotRunning()// kotlin extension function check service state 在这一行之后,我正在发送otto事件到以前启动的服务 BusStation.getBus().post(DownloadEvent()) // Actually this line fired before start of service 但是即使是注册了事件,下载服务也没有收到这个事件。 在调试之后,我发现Otto事件在服务实际启动之前正在触发,因此它没有收到任何事件 所以有没有什么办法知道什么时候android服务正常启动,以接收otto事件

类没有发现一些构建异常

我把片段翻译成Kotlin。 里面有我用Otto的@Subscriebe标签标记的方法来监听网络通信。 当我运行一些构建这个片段是创建和可见的,但是当数据下载和Otto试图调用这个标记的方法我得到了ClassNotFoundException : Fatal Exception: java.lang.NoClassDefFoundError: Failed resolution of: (…)/app/ui/fragments/ProfileCoverFragment$fillFromUserProfile$1; at (…).ui.fragments.ProfileCoverFragment.fillFromUserProfile(ProfileCoverFragment.kt:136) at java.lang.reflect.Method.invoke(Method.java) at java.lang.reflect.Method.invoke(Method.java:372) at com.squareup.otto.EventHandler.handleEvent(EventHandler.java:89) at com.squareup.otto.Bus.dispatch(Bus.java:386) at com.squareup.otto.Bus.dispatchQueuedEvents(Bus.java:369) at com.squareup.otto.Bus.post(Bus.java:338) at (…).communication.DefaultCallback.success(DefaultCallback.java:32) at (…).app.communication.CommunicationManager$7.success(CommunicationManager.java:463) at (…).app.communication.CommunicationManager$7.success(CommunicationManager.java:459) at retrofit.CallbackRunnable$1.run(CallbackRunnable.java:45) at android.os.Handler.handleCallback(Handler.java:739) at android.os.Handler.dispatchMessage(Handler.java:95) at android.os.Looper.loop(Looper.java:135) at android.app.ActivityThread.main(ActivityThread.java:5257) at java.lang.reflect.Method.invoke(Method.java) at java.lang.reflect.Method.invoke(Method.java:372) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:903) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:698) 重建问题后暂时修复。 但它仍然可以在一些版本中找到。 我正在寻找一种方法来获得稳定的构建过程与gradle。