Rest Android server interraction - sizzlelab/sensors GitHub Wiki
There are two projects in the repository:
RestAndroid - provides connection and data exchange with the server. Links your application that gathering sensors data with the server. RestServerTest - gets data from the Android phone using REST protocol.
How to use
-
Specify your server address in RestAndroid project using the file res/values/strings.xml property server_address
-
add RestAndroid library to you Android application.
-
Initialize RestAndroid library's object to prepare it for sending messages to the server:
AndroidRestlet.init(getApplicationContext());
-
When you sensor data updates call AndroidRestlet object to send it to the server. The data is sent in text
String
formatAndroidRestlet.sensor.updateSensor("data");
-
Configure server to receive these messages:
-
In RestServerTest project edit file
hibernate.cfg.xml
to set up your database configuration (e.g. username, password, address, databasename) -
Launch server application in RestServerTest project running fi.soberit.ubiserv.MainServerComponent.java as a java application. The application automatically creates tables in the database if they do not exist hence it will happen on the first start when the message is received.