Skip to content

Rest Android server interraction

valeriyv edited this page May 3, 2012 · 4 revisions

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 1 add RestAndroid library to you Android application. 2 Initialize RestAndroid library's object to prepare it for sending messages to the server:

AndroidRestlet.init(getApplicationContext()); 3 When you sensor data updates call AndroidRestlet object to send it to the server. The data is sent in text String format AndroidRestlet.sensor.updateSensor("data"); in 4 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) 5 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.

Clone this wiki locally