I'm trying to send a string to php server from an app, the string should be sent (the method executes without an error), but the server isn't receiving anything. Here's what I'm doing, I followed another SO thread so I'm don't really know if what I'm doing is correct.
protected String doInBackground(String... params) {
HttpClient httpclient = new DefaultHttpClient();
HttpPost httppost = new HttpPost(url);
try {
StringEntity se = new StringEntity(data);
httppost.setEntity(se);
httpclient.execute(httppost);
} catch (ClientProtocolException e) {
} catch (IOException e) {
}
return null;
}
Here's the code that sends the data to the server in a web app.
function send_message( message ) {
data = "data";
$.ajax({
type: 'POST',
url:"url",
data: data,
success: function() {
$("#message_sent").val( "true" );
},
error: function(json) {
},
abort: function( json ) {
}
});
}
So basically I want to translate the js code that sends the data into java code and use it in the app.