I\'m writing an Android App and I\'m looking for the fastest (In terms of setup) way for me to send data to a server and receive information back on request.
We\'re
private void sendData(ProfileVO pvo) {
Log.i(getClass().getSimpleName(), "send task - start");
HttpParams p=new BasicHttpParams();
p.setParameter("name", pvo.getName());
//Instantiate an HttpClient
HttpClient client = new DefaultHttpClient(p);
//Instantiate a GET HTTP method
try {
HttpResponse response=client.execute(new HttpGet("http://www.itortv.com/android/sendName.php"));
InputStream is=response.getEntity().getContent();
//You can convert inputstream to a string with: http://senior.ceng.metu.edu.tr/2009/praeda/2009/01/11/a-simple-restful-client-at-android/
} catch (ClientProtocolException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
Log.i(getClass().getSimpleName(), "send task - end");
}
Check out WWW.viewstreet.com developing an Apache plugin specifically for android serverside development for Java programmers
The easiest solution for you would be to use the apache http client to get and post JSON requests to a php server.
The android already has a JSON builder/parser built-in, as does PHP5, so integration is trivial, and a lot easier than using its XML/Socket counterparts.
If you want examples of how to do this the android side of things, here is a twitter API that basically communicates with twitter via their JSON rest API.
http://java.sun.com/docs/books/tutorial/networking/sockets/
This is a good background tutorial to Java socket communication.