How can I update information in an Android Activity from a background Service

前端 未结 5 1967
北海茫月
北海茫月 2020-11-29 17:06

I am trying to create a simple Android application that has a ActivityList of information, when the application starts, I plan to start a Service that will be constantly cal

5条回答
  •  情话喂你
    2020-11-29 17:35

    I am really, really wondering why no one mentioned a simple approach using an EventBus by whatever library. This is of course if you are not using RX. My personal favorite is EventBus by GreenRobot. https://github.com/greenrobot/EventBus

    With just a couple of lines of code, and no interfaces. Fire an event, and listen for it wherever you want. It is decoupled, it is thread safe, and it will not crash your app.

提交回复
热议问题