Reputation: 3968
I am planning to implement a chat application in Android, and need to make a few design decisions related to polling the server for updates:
How often should I poll for new messages? Will polling every minute be a good choice?
How can real time chat be supported? Should the polling be done every 5 seconds in case the user sends message and then return to long polling interval in case no new message is received?
I also need to make sure the application does not drain the battery quickly. I need to design the application on similar lines as WhatsApp. I am not sure how does it manage polling, but I know its not a battery killer.
Upvotes: 1
Views: 2527
Reputation: 25793
You should look into XMPP.
WhatsApp uses a modified version of XMPP.
Here's a tutorial to get started.
Upvotes: 3
Reputation: 713
Upvotes: 0
Reputation: 355
For the chat I'd make two different kind of polling. First if the application is in background (every minute or something like this) and if the app is started every second or maybe long polling: http://en.wikipedia.org/wiki/Push_technology#Long_polling
Upvotes: 0
Reputation: 3542
Polling is not the answer for this type of application. If your application is solely Android base you should look at the Google Cloud Messaging Framework (http://developer.android.com/google/gcm/index.html).
This allows you to push messages to individual clients over xmpp (or http ping to pull). This way they can get updates almost instantly.
Upvotes: 0