Question

I have that works offline and synchronizes with server. So user is doing changes and all changes are synchronized (both ways) when there is Internet connection. Server is also sending push to client when new data arrives from another source (e.g. WWW). Client tries to get new data from server after getting push.

I had it all done on manually created thread running in the background. I'm refactoring this code and I thought that I could move it to IntentService. All I need from this "module" is to:

  • Synchronize, if there is Internet connection and sth new to synchronize (after change made by user of after receiving push from server)
  • Retry synchronization if there is Internet connection has changed and sth to synchronize

Is this a good idea to create multiple intent services in android app?

Was it helpful?

Solution

IntentService is far better than code Threads from scratch and you can have more than one Service "running" (be carefull about the concept of "running" service). And remember that more Services "running" at same time means more Threads and more resources being drained.

But if if you don't need real time synchronization (do you really need it? are you sure?) take a look at SyncAdapters, it's a good way to let Android itself handle some sync issues like lack of internet connection:

http://developer.android.com/training/sync-adapters/index.html

Also Google Cloud Messaging can help you:

http://developer.android.com/google/gcm/index.html

Important note about SyncAdapters: you can hint it about when to synchronize but it can have delays... so be carefull about how this affects your application.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top