I have a problem with interacting with PHP server.
Asked
Active
Viewed 71 times
0
-
@FirstOne How can I change my code to Form-data? I am so confused. Thank you. – LunarS Jul 27 '16 at 22:59
-
Can u put $_POST value in php? just write var_dump($_POST); in php file. Prolly php expecting array and you are sending json. – Mehmet SÖĞÜNMEZ Jul 27 '16 at 23:00
-
@MehmetSÖĞÜNMEZ I don't write PHP, I am just responsible for interacting. – LunarS Jul 27 '16 at 23:02
-
[**Sending POST data in Android**](http://stackoverflow.com/questions/2938502/sending-post-data-in-android) – FirstOne Jul 27 '16 at 23:02
-
/\ For the chosen answer, take a look at the `Older Answer` part – FirstOne Jul 27 '16 at 23:03
-
@FirstOne Thanks a lot! However, our product requires compatible with 6.0, is there anyway can fix it? Thank you! – LunarS Jul 27 '16 at 23:06
-
Well, the `Older Answer` part is just like you are doing (`HttpClient` & `HttpPost`). If you are asking how to upgrade the code, that's a completely different question.. You'll have to search about that ^^ – FirstOne Jul 27 '16 at 23:10
-
@FirstOne Thank you, I will try to figure that out. ^^ – LunarS Jul 28 '16 at 01:24
1 Answers
0
Try to use Android volley, it is easy and simple with lots of functionality.
Reffer Following Block it might helps you..
StringRequest stringRequest = new StringRequest(Request.Method.POST, URL,
new Response.Listener<String>() {
@Override
public void onResponse(String response) {
//GET RESPONSE HERE
}
},
new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError error) {
//ERROR Message
}
}){
@Override
protected Map<String,String> getParams(){
Map<String,String> params = new HashMap<String, String>();
// Pass POST data here [ params.put(key,value) ];
params.put(KEY_USERNAME,username);
params.put(KEY_PASSWORD,password);
params.put(KEY_EMAIL, email);
return params;
}
};
RequestQueue requestQueue = Volley.newRequestQueue(this);
requestQueue.add(stringRequest);

Nikhil
- 312
- 2
- 13