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

前端 未结 5 1970
北海茫月
北海茫月 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:14

    This sound like a good candidate for the Observer Pattern. Basically your activity (The Observer) will register itself with the background service (The Observable) and you can push or pull data from your Activity. Your Observer in this case will be your Activity and the Observable will be your Service.

    If you know nothing about Design Patterns buy "Head First Design Patterns", it is easy to read and is full of great information.

    PS: I am reading it now.

提交回复
热议问题