http-request icon indicating copy to clipboard operation
http-request copied to clipboard

unable to get the post parameter

Open navotera opened this issue 9 years ago • 1 comments

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 avatar Oct 03 '15 16:10 navotera

@navotera : Do you have updates on this issue, have you managed to solve it?

alexszilagyi avatar Jul 07 '17 08:07 alexszilagyi