I am new to Java... But I have tried to achieve this in JS successfully, but I don't know how to do same in Java.
Question
I am building an android app in Android Studio, and I have this code that sends a POST request to a PHP page in my local server.
String url = "http://localhost/inc/signUp.php";
StringRequest rqst = new StringRequest(Request.Method.POST, url, new Response.Listener<String>() {
@Override
public void onResponse(String response) {
//get my response in an Array
}
}, new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError error) {
}
});
And in my signUp.php I am outputting the response JSON_ENCODE
$data = array('state', 'value');
echo json_encode($data);
Now on the Java code, I want to get the response in an array but I don't know how to do that
onResponsemethod you can decode it using a library like Gson.