0

I'm looking for some suggestions to essentially do an "ajax long poll" but with native android components. There will be no HTML in my app so using something like SignalR is out of the question. I really don't want to go the sockets route unless I absolutely have to, but I want something that works as close to the same way as possible.

The server will return a simple web service (JSON) response.

I'm not entirely opposed to polling on an interval if you think that is what's best. Basically, I just want to be able to receive "updates" from the server as they occur in as close to real-time as possible.

Any suggestions/samples to accomplish this natively with android would be greatly appreciated.

TIA

Christopher Johnson
  • 2,629
  • 7
  • 39
  • 70
  • Explaining why do you need continuous polling might help us understand your problem as polling is a battery killer for mobile devices. – Morrison Chang Jun 15 '13 at 03:25
  • I'm creating a social media type app where users can submit pictures and comments. I'd like for all users who are connected to have the new pictures and comments updated in as close to real-time as possible. – Christopher Johnson Jun 15 '13 at 16:16

1 Answers1

0

Either check out WebSockets for near realtime server communication or GCM for server push notifications.

SimonSays
  • 10,867
  • 7
  • 44
  • 59
  • like I said, I really don't want to go with sockets. I'm also not really looking for push notifications. I need the client to just "stay connected" for updates from the server. Any other ideas? – Christopher Johnson Jun 15 '13 at 01:21
  • If you don't want GCM, go with other XMPP soutions, we use it to notify our clients with json messages. – Milan Jun 15 '13 at 03:35
  • I've done a little more reading about GCM but still have some questions about it. I've used it to send push notifications to alert users about something when the app is "closed". Can it also be used as a simple message bus to alert users who are currently "in" the app to make a request to the server? That would suit my needs if it can. – Christopher Johnson Jun 15 '13 at 22:49
  • Well it doesn't matter if the app is open or closed, you will get the message anyways. The thing with GCM is that messages can be delivered delayed. There is a message throttling, but i think you can disable it with a "time to life" of zero. – SimonSays Jun 17 '13 at 16:54