Android Developer Question:
Download Questions PDF

Explain me what is the difference between Service and IntentService? How is each used?

Android Developer Interview Question
Android Developer Interview Question

Answer:

Service is the base class for Android services that can be extended to create any service. A class that directly extends Service runs on the main thread so it will block the UI (if there is one) and should therefore either be used only for short tasks or should make use of other threads for longer tasks.

IntentService is a subclass of Service that handles asynchronous requests (expressed as “Intents”) on demand. Clients send requests through startService(Intent) calls. The service is started as needed, handles each Intent in turn using a worker thread, and stops itself when it runs out of work. Writing an IntentService can be quite simple; just extend the IntentService class and override the onHandleIntent(Intent intent) method where you can manage all incoming requests.

Download Android Developer Interview Questions And Answers PDF

Previous QuestionNext Question
Explain me activities?Explain me onSavedInstanceState() and onRestoreInstanceState() in activity?