0

I'm planning to write up an android App that will collect some data from a smartphone and periodically send the data to some publicly accessible machine (i.e., the machine has a public IP address). What is the best approach to doing this? Is there any good sample code or skeleton available online?

At this point the communication is one way, i.e., from smartphone to external machine.

Slayer
  • 2,391
  • 4
  • 21
  • 18
  • Could you give me a little more information on what you intend to do with the data on the server? – Jud Nov 15 '13 at 01:04
  • We are planning to gather some sensor data from different smart phones. So typically different phones will send data periodically. We are having trouble with the PHP server script. We see that the app tries to send data to the server but the server refused the connection. And this was just for testing localhost as the server from an android emulator. So don't know where we are going wrong. – Slayer Nov 16 '13 at 21:40
  • Are you able to hit the server from another client device (e.g. a simple web browser?) – Jud Nov 16 '13 at 21:48
  • OK solved it with pyhton :) – Slayer Nov 21 '13 at 22:28

1 Answers1

1

HTTP is the ideal solution for an application like this. Run a web server on the external machine and POST data from the app to the server.

Info on how to do this from Android can be found here: How to send a data to a web server from Android.

As for the web server side of things, there are a ton of different solutions available. It all depends on your level of knowledge, what languages you're familiar with, and what you intend to do with the data once it arrives.

CGI is the classic web server tool for handling POST requests, but there are better techniques now. For example, the Java Servlet API if you like Java, WSGI if you like Python, PHP is a common server side language also.

Community
  • 1
  • 1
Jud
  • 1,158
  • 1
  • 8
  • 17
  • Personally I'm a Python guy and love the [Bottle](http://bottlepy.org/) micro framework for writing simple web servers. – Jud Nov 15 '13 at 00:51