krtkush
krtkush

Reputation: 1528

Exchanging data between android apps through a server

For learning purposes, I'm making an android app which will have to exchange data with a server Now, I'm familiar with Android programming so that is not a problem. The problem is that I have never set up a server and exchanged data with an app through that server.

The following is the requirement:

  1. Send data from one device to another through an app.
  2. The exchange of data will be done with the help of a LAMP server. The devices will be registered with the server, i.e. they'll have their 'accounts' on it.
  3. Device 1 sends data to the server, the server pushes it to Device 2 which too will have the app.

The following is what I have thought of, till now:

  1. Create an app
  2. Set up a LAMP server
  3. App sends the required data, from device 1, to the server in XML format
  4. The server accepts the XML and parses it (using DOM or maybe SAX). The XML will contain the details of the device (Device 2) to which it has to forward that XML file.
  5. Forwards the XML data to Device 2.

Questions:

  1. Is my approach correct? Please guide me because I have never done this. My closest experience is that of using a web service called Parse.
  2. Is setting up a LAMP server enough? I don't think so. I guess I'll have to create an application on the server which will accept the XML file, parse it and forward it. Also, the server needs to be able to save all the devices info on it. On what language should I create this application? PHP? Is there an API/program which I can implement to achieve the functionality?
  3. I'm assuming I'll have to use HTTPClient to achieve my goals, correct?
  4. What else do I need to know/implement in my case?

I'll be really thankful if somebody can answer my questions. I'm a complete newbie at this. Thank you :)

Upvotes: 1

Views: 3860

Answers (2)

user2622833
user2622833

Reputation:

Is my approach correct?

You have the right idea, however you are more likely to wish to pass data to your server via POST or GET requests than as XML. You can pass values and arrays via these methods and it won't require the effort of parsing the XML with xpath or something similar.

Returning data to the mobile device, you could use XML, however JSON is currently the format of choice for API's.

On what language should I create this application

PHP is a suitable language, other possibilities include ruby on rails, asp.net, python etc. (Lots of options).

Is there an API/program which I can implement to achieve the functionality?

Recieving GET/POST requests and transferring data to a database/flatfile should be fairly straight forward using the core libraries of the language used.

I'm assuming I'll have to use HTTPClient to achieve my goals, correct?

Yes

What else do I need to know/implement in my case?

Decide how your going to store the data server side, if your using a database you will need to set that up and do a bit of research into SQL, if you can't get access to an SQL server, you have the options of SQLITE (the database is stored in a portable file) or using flatfiles.

Upvotes: 3

Cote Mounyo
Cote Mounyo

Reputation: 13965

Since this is an android question, why not simply use app engine to create an appengine connected android (ACA)? https://developers.google.com/eclipse/docs/endpoints-androidconnected-gae

Also you can use GCM which is easy to implement http://developer.android.com/google/gcm/index.html (since the default ACA project comes with it pre-implemented)

Upvotes: 0

Related Questions