Android and RESTful services

后端 未结 3 908
野性不改
野性不改 2020-12-09 14:05

In Virgil Dobjanschi talk during Google I/O he mentioned using Services for doing the fetching and then using a callback to notify the Activity whe

相关标签:
3条回答
  • 2020-12-09 14:42

    Option #1: Service sends a broadcast Intent, which the Activity catches via a BroadcastReceiver registered via registerReceiver().

    Option #2: If the Activity is binding to the Service, have the Activity pass a listener to the Service, which the Service invokes when the work is complete.

    Option #3: Service doesn't do much, but the ContentProvider calls notifyChange() when the data changes, which can ripple back through to the Activity and/or its Cursor on the data.

    Option #4: Singletons, which should be avoided.

    ...

    Option #237: Service sends a letter via FedEx to the Activity. :-)

    ...

    All that being said, once they release the Twitter app as open source, you'll know for certain what the Twitter app does.

    0 讨论(0)
  • 2020-12-09 14:52

    Check out the Google I/O 2010 app. It uses the pattern he was referring to. It uses Option #2 from CommonsWare's answer.

    0 讨论(0)
  • 2020-12-09 15:03

    i think they're talking ab out using AIDL to communicate between the activity & the service...

    0 讨论(0)
提交回复
热议问题