Service vs IntentService in the Android platform

后端 未结 11 611
挽巷
挽巷 2020-11-22 03:38

I am seeking an example of something that can be done with an IntentService that cannot be done with a Service (and vice-versa)?

I also bel

11条回答
  •  广开言路
    2020-11-22 03:56

    An IntentService is an extension of a Service that is made to ease the execution of a task that needs to be executed in background and in a seperated thread.

    IntentService starts, create a thread and runs its task in the thread. once done, it cleans everything. Only one instance of a IntentService can run at the same time, several calls are enqueued.

    It is very simple to use and very convenient for a lot of uses, for instance downloading stuff. But it has limitations that can make you want to use instead the more basic (not simple) Service.

    For example, a service connected to a xmpp server and bound by activities cannot be simply done using an IntentService. You'll end up ignoring or overriding IntentService stuffs.

提交回复
热议问题