0

If we define an Service to handle our REST API

Should this service be bound or IntentService ?

As we need to access it from many activities and need it to hold current Client-Server state attributes, I think we should choose the Bound Service, but am I right?

Summary
So finally I decided to combine Singleton and Sync Adapter models. Sync Adapter for large datasets and Singleton for quering non-data calls.

Marek Sebera
  • 39,650
  • 37
  • 158
  • 244

3 Answers3

2

A bound service would be the best choice if you need to maintain state. IntentService is more for a worker queue type of invocation, where the service starts, does some work and then stops when there's no more work.

botteaap
  • 5,790
  • 3
  • 29
  • 35
1

The only advatage of using a Service instead of a singleton is that if your process has a started Service, the process is less likely to be killed by the OS (see this answer - Android: When to use Service vs Singleton?).

So I would just use a singleton instead of a Service. And perhaps start a dummy Service as a way of telling the OS that you want to stay in memory as long as possible. When you are ok with your process being killed, stop the dummy Service.

Community
  • 1
  • 1
fhucho
  • 34,062
  • 40
  • 136
  • 186
1

Why don't you try using a SyncAdapter? Take a look at this blog post.

Macarse
  • 91,829
  • 44
  • 175
  • 230