Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android - Run in background - Service vs. standard java class

In Android, if I want to do some background work, what is the difference between

Creating a Service to do the work, and having the Activity start the Service VS. Creating a standard java class to do the work, and having the Activity create an object of the class and invoke methods, to do the work in separate thread.

like image 434
Chris Avatar asked Jun 18 '10 05:06

Chris


1 Answers

Doing your own threads is overkill, there are solutions for this, so you don't have to worry about the hard parts of concurrency. Have a look at AsyncTask or IntentService. If you go for a service please keep in mind that your service can be killed at any time.

like image 174
zehrer Avatar answered Dec 30 '22 04:12

zehrer