iFixit / iFixitAndroid

Official iFixit Android App
https://play.google.com/store/apps/details?id=com.dozuki.ifixit
GNU General Public License v3.0
162 stars 88 forks source link

API: Use an AsyncTask rather than a Service #170

Closed marczych closed 10 years ago

marczych commented 10 years ago

Long running background services were once strongly recommended against by the Android developer docs. I can no longer find the article that stated that, though.

In any case, using a Service to perform API calls is a bit heavy handed. The actual request was performed in an AsyncTask inside the Service anyway. All it really did was add an extra layer of complexity:

  1. An Intent had to be created to start the service.
  2. Arguments were serialized and unserialized.
  3. Retrying dead events required Activities to bind to the service and use interprocess communication.

Additionally, ApiService was kept alive and running for weeks after the app was closed unless the user explicitly killed the app.

Converting ApiService to a class with static methods only resulted in simplifications and performance improvements. One motiviation to use a Service was to use it to download guides for offline storage. The backup framework already has a nice system for handling that so it would only cause problems to try and use ApiService to do the background work.