A
A
Andrey Kovalchuk2016-03-12 10:28:28
Java
Andrey Kovalchuk, 2016-03-12 10:28:28

How to organize communication between client (Android) and server (Java)?

Good day.
There is a task: to figure out a client-server application with a server part on a PC written in Java, and a client part on an Android device.
The client sends a request for data, the server receives the request and sends the requested data.
Based on the task, execution in the form of frequent surveys is required.
What is the best way to organize communication between the client and the server? And literature, if possible.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
I
Ilya, 2016-03-12
@mrkovalchuk

The simplest thing is to write a REST API on the server, give the client data in JSON via HTTP.
You can quickly throw in a server application using this one , for example. You can request anything over HTTP in an Android application using Volley.

U
uvelichitel, 2016-03-12
@uvelichitel

Based on the task, execution in the form of frequent surveys is required.

In such cases, the websockets protocol is usually used, which makes it possible to reuse the connection and allows server push. For server push, google also provides a service https://developers.google.com/cloud-messaging/ with the ability to subscribe and broadcast.
If you want to write not on WebView but closer to hardware, then no one on android has canceled unix sockets
import java.net.InetAddress;
import java.net.Socket;

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question