4

i want a two communication between server and Android. From Android want to send my current location coordinates to server after each 10 minutes. i can send message or images to server at any time. Similarly from server i want to send data to Android whenever needed.

What should be the architecture of my application.

Communication from Android to server and Server to Android is independent of each other i should not ask it as a two way communication but infact i want communication from both sides to each other any time.

Should i use a Web service of any kind or just network sockets or Something else.

waseemwk
  • 1,499
  • 3
  • 15
  • 44

2 Answers2

3

You can use websockets or...

Simply send data from phone to the server using normal request. When you want send something from server to telephone you can use push notifications (C2DM) and if you receive such push message you know that server has data for you and telephone can download it using normal request;-). It depends what data you want to send. Sometimes this approach will be good, sometimes it's better to use websockets, TCP sockets or even XMPP protocol ;-)

radzio
  • 2,862
  • 4
  • 26
  • 35
  • This mean Server cannot send data explicitly to Android rather it will ask the Android phone to come and get the Data from the Server? – waseemwk Feb 22 '12 at 07:36
  • Id you're using C2DM yes - server can only ask phone to come and get data from the server. If you will use sockets - you will be able to send data directly to Android. – radzio Feb 22 '12 at 14:06
0

You can Use Acknowledge for the same. You need to Implement ACK/NACK Logic in your code. When you are sending Data just wait for ACK for a particular time period. If ACK is not received the you need to send NACK for the same. Here you need to use a session-id ( a kind of id for communication at both side, which can be any random number ).

You can use this Logic at both the side.

Lucifer
  • 29,392
  • 25
  • 90
  • 143
  • like what you were expecting ? – Lucifer Feb 22 '12 at 07:34
  • i was requesting to suggest me an architecture of communication between Server and Android. Should i use Web service OR Sockets OR something else that let me transfer data between Android and a Server. – waseemwk Feb 22 '12 at 07:42
  • oh ok, sorry for my mis-understanding, you can use Web Services as per my Answer – Lucifer Feb 22 '12 at 07:46
  • why shouldn't i use Sockets instead of using Web Service. which one is fast because i want data transfer to be fast and moreover at a time many thousands of Clients will be connected to the same server. can u elaborate please. – waseemwk Feb 22 '12 at 08:36
  • well I have not used SocketConnection still , I use web services for sending receiving data. so i asked you for same – Lucifer Feb 22 '12 at 08:43