Ofek Ron
Ofek Ron

Reputation: 8578

Android Service Class

What is it about android Service class that makes it suppose to "run in the background" as it documented everywhere? which thread lives on to run on the background? and what about all Threads that are being started in onStartCommand()? do they live as long as they have code to run or will they die whenever stopSelf() or the alternate is called?

enlighten me please...

Upvotes: 1

Views: 170

Answers (1)

Guykun
Guykun

Reputation: 2779

Android services run on the main thread of the activity they are started from.

Any other threads you then start from the service will run independently and will need to be stopped. This can be easily done with a

if (running)

block set by whether the service is started or stopped.

Upvotes: 2

Related Questions