1

From this link: https://www.toptal.com/android/android-threading-all-you-need-to-know

Service runs in the main thread of its hosting process; the service does not create its own thread and does not run in a separate process unless you specify otherwise.

This means that the service runs in the main thread of the app that starts it. If so, why doesn't the app get blocked when the service is running?

Any help will be appreciated.

javadroid
  • 1,421
  • 2
  • 19
  • 43
Droid Man
  • 21
  • 3
  • A Service is not a separate process. https://stackoverflow.com/a/11099437/2383176 – javadroid Jan 19 '20 at 11:22
  • I understand that. – Droid Man Jan 19 '20 at 11:40
  • When the main thread of an App is busy doing operation than UI operations, we get ANR, right? Why doesn't it happen with services, even though it runs in the main thread? – Droid Man Jan 19 '20 at 11:42
  • not always, depends on what you done with your code. you need to more reading about services, service not always run in background by default. check this for more detail: https://stackoverflow.com/questions/30316906/why-use-service-if-it-runs-in-the-same-thread-in-android – javadroid Jan 19 '20 at 16:19

0 Answers0