I am trying to implement data transfer between a back-end server and the android device which is a request from device to server for information and the server responds(UDP use because it is faster and the functionality of TCP isn't needed, I guess...)
Where do I begin for implementing this? I have looked at the Android Docs for DatagramSocket/Packet/SocketImplFactory as well as InetAddress and SocketAddress.
Is this the right direction? Right now I am using HTTP Post requests, is any of that code recyclable?
HttpClient httpclient = new DefaultHttpClient();
HttpPost httppost = new HttpPost(url);
List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>(2);
if (fleetID != null) {
nameValuePairs.add(new BasicNameValuePair("fleetID", fleetID));
}
nameValuePairs.add(new BasicNameValuePair("user", username));
nameValuePairs.add(new BasicNameValuePair("password", password));
httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs));
HttpResponse response = httpclient.execute(httppost);
//TODO: response failure? need to ensure success
HttpEntity resEntity = response.getEntity();
String strEntity = EntityUtils.toString(resEntity);
//Log.i("RESPONSE", strEntity);
return (strEntity);