I need the service to have a steady connection with the server.
Activity and service should have bi-directional communication.
Here are the options I know
- Use intent service
- Extend Service class ( make it run in a different process ) and communicate using Messaging
My thoughts:
Intent services are nice, they run in their own thread, but they stop when the task is done. I don't want that. For example, if for some reason the connection is interrupted it should try to reconnect, instead of exiting the service
Extending service class makes sense. I have previously worked on a project that used Messaging for communicating with the service, the problem here is that as the project grows, it becomes hard to manage the communication.
I'm looking for an approach, where the service runs in a different process or thread, should start again if terminated for any reason (something like START_STICKY).
Also it would be nice if the communication is easy and something like Otto or EventBus can be used.
Edit : So the question is, what's the ideal way to implement it, which saves me from dealing with Messages and gives a STICKY service.