I have written code for POST request from an android application which will run a php file on the server.
    String url = "http://****/****/Servlets.php";
    RequestQueue MyRequestQueue = Volley.newRequestQueue(this);
    StringRequest MyStringRequest = new StringRequest(Request.Method.POST, url, new Response.Listener<String>(){
        @Override
        public void onResponse(String response){
            //code when server responds
        }
    },new Response.ErrorListener(){
        @Override
        public void onErrorResponse(VolleyError error){
            //Code if error is there
            int test2 = 1;
        }
    }){
        protected Map<String, String> getParams() {
            Map<String, String> MyData = new HashMap<String, String>();
            MyData.put("key",st);
            return MyData;
        }
    };
    MyRequestQueue.add(MyStringRequest);
Code for the Php file is calling a java file and getting some string value. How do I return that string value to the android device that can be passed to onresponse() parameter? Also does the on response wait or how can we handle it ?
Please suggest.