I am creating an app in Android Studio. I am trying to send 5 parameters to a database through a rest service I have previously configured. I have tested the webpage through a browser plugin and a post request and is working fine, so I know for sure the problem is from the app itself. I also made sure the data I was sending was also good(locationX, locationY, time, date, username). Does anyone have any idea why this isnt working?
public void onClickSendCoordinates(View v)
{
final EditText textbox3 = (EditText) findViewById(R.id.textbox3);
String date = DateFormat.getDateInstance().format(new Date());
String time = DateFormat.getTimeInstance().format(new Date());
String url = "http://somewebsite.com/index.php";
String locationX = textbox2.getText().toString();
String locationY = textbox1.getText().toString();
String username = "user_1";
EditText textbox4 = (EditText) findViewById(R.id.textbox4);
textbox4.setText(username + locationX + locationY + date + time);
AsyncHttpClient httpClient = new AsyncHttpClient();
RequestParams params = new RequestParams();
params.put("username", username);
params.put("locationX", locationX);
params.put("locationY", locationY);
params.put("date", date);
params.put("time", time);
httpClient.post(url, params, new TextHttpResponseHandler() {
@Override
public void onSuccess(int statusCode, Header[] headers, String res) {
//called when response HTTP status is "200 OK"
textbox3.setText("Success");
// Toast.makeText(getApplication(),"Sending URL " + url + "with params " + params.toString(), Toast.LENGTH_LONG);
}
@Override
public void onFailure(int statusCode, Header[] headers, String res, Throwable t) {
textbox3.setText("Failure");
// Toast.makeText(getApplication(), "Sending URL " + url + "with params " + params.toString(), Toast.LENGTH_LONG);
//called when response HTTP status is "4xx" (eg. 401, 403, 404)
}
});
}