Service vs IntentService in the Android platform

后端 未结 11 630
挽巷
挽巷 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 04:14

    If someone can show me an example of something that can be done with an IntentService and can not be done with a Service and the other way around.

    By definition, that is impossible. IntentService is a subclass of Service, written in Java. Hence, anything an IntentService does, a Service could do, by including the relevant bits of code that IntentService uses.

    Starting a service with its own thread is like starting an IntentService. Is it not?

    The three primary features of an IntentService are:

    • the background thread

    • the automatic queuing of Intents delivered to onStartCommand(), so if one Intent is being processed by onHandleIntent() on the background thread, other commands queue up waiting their turn

    • the automatic shutdown of the IntentService, via a call to stopSelf(), once the queue is empty

    Any and all of that could be implemented by a Service without extending IntentService.

提交回复
热议问题