http-request
http-request copied to clipboard
unable to get the post parameter
my server got any $_POST variable when posting data to server using android. Here my android code
public void onClick(View v) {
Map<String, String> data = new HashMap<String, String>();
data.put("name", "A User");
data.put("status", "Okeyssss");
String url = "http://10.0.3.2/android_server/";
DownloadTask task = new DownloadTask(data);
task.execute(url);
}
});
}
private class DownloadTask extends AsyncTask<String, Long, String> {
private Map<String, String> formData = null;// post data
public DownloadTask(Map<String, String> data) {
formData = data;
}
protected String doInBackground(String... urls) {
try {
if(HttpRequest.post(urls[0]).form(formData).created())
return "Created";
} catch (HttpRequest.HttpRequestException exception) {
return "error";
}
return "unknown";
}
protected void onProgressUpdate(Long... progress) {
Log.d("MyApp", "Downloaded bytes: " + progress[0]);
}
protected void onPostExecute(String result) {
//Log.d("MyApp", result);
Toast.makeText(getApplicationContext(), result, Toast.LENGTH_LONG).show();
}
}
@navotera : Do you have updates on this issue, have you managed to solve it?