tags:

views:

188

answers:

2

I have an application that needs to send messages, repeatedly to the server. I'm currently using AJAX from the phone's browser and it works fairly reliably, but, as with all things cell-phone, not 100%. I'm curious if using Android and opening a socket to the server would give me any additional reliability, or if it would suffer from the same communication troubles that hinder the AJAX transmission.

all thoughts appreciated.

+2  A: 

This really depends on what you are talking about doing, and why your communication fails.

However, in general if you can get to running your own code on the phone, you have more control over retry logic, exception handling and logging related to communications. When in a web-context using AJAX the browser is running the show, and you rely on it for proper management etc.

Mitchel Sellers
the communication fails sporadically due to crappy phone signal strength. What I'm wondering is if I open a socket, is that more reliable than simply sending a message and then doing some timeout based verification if the server's response doesn't come back in a timely manner.
Dr.Dredel
More than likely, you are going to get a better result running as an Application, but it isn't going to be guaranteed. With a cell phone, getting guaranteed service is not an easy feat.
Mitchel Sellers
+1  A: 

If you are using AJAX in the phone's browser, it sounds like you have a browser-based app. Are you sure you want to require the user to install extra software to use your webapp?

On the other hand, if this is already a custom application that just uses the browser for its user interface, then nevermind. You will still need to wire your Java code in a Javascript harness, but that isn't too bad.

Daniel Yankowsky
there's nothing explicitly "java"-ish about the client. It simply needs to send messages to the server as rapidly as it can. The problem I'm detecting at the moment is that if the connection is flaky (bad phone reception) some messages simply get lost in the ether (some don't make it to the server, others don't get back to the phone). I can write verification code in Javascript just as easily as I can in Java. I was wondering if there's an inherently more reliable approach pre-packaged in Android.
Dr.Dredel
By Java, I was implying that you would use Java to create and use the socket.
Daniel Yankowsky