Câu hỏi phỏng vấn Android
Câu hỏi

Explain key differences between Service and IntentService

Câu trả lời

Here are the key differences between Service and IntentService in Android:

Usage

  • Service can be used for both short and long running tasks, while IntentService is best suited for long-running tasks that don't need to be run again[1][2][3].
  • Service can handle multiple requests simultaneously, while IntentService handles one request at a time and stops itself when the request is complete[1][4].

Threading

  • Service runs on the main thread of the application by default, so you need to create a new thread to avoid blocking the UI[1][2][3].
  • IntentService runs on a separate worker thread, so it doesn't block the main thread[1][2][3].

Lifecycle

  • Service can be stopped and restarted as needed, while IntentService cannot be restarted after it is stopped[1][4].
  • Service requires manually calling stopSelf() or stopService() to stop, while IntentService stops itself automatically when all intents have been processed[1][2][...
middle

middle

Gợi ý câu hỏi phỏng vấn

junior

What is an AsyncTask ?

senior

What is AIDL?

senior

Discuss Singletons vs. Application Context for app-global state

Bình luận

Chưa có bình luận nào

Chưa có bình luận nào