how to use volley string request in android

Solutions on MaxInterview for how to use volley string request in android by the best coders in the world

showing results for - "how to use volley string request in android"
Nicolò
26 Jun 2020
1String uri = String.format("http://somesite.com/some_endpoint.php?param1=%1$s¶m2=%2$s",
2                           num1,
3                           num2);
4
5StringRequest myReq = new StringRequest(Method.GET,
6                                        uri,
7                                        createMyReqSuccessListener(),
8                                        createMyReqErrorListener());
9queue.add(myReq);
Luca
14 Sep 2018
1StringRequest myReq = new StringRequest(Method.POST,
2                                        "http://somesite.com/some_endpoint.php",
3                                        createMyReqSuccessListener(),
4                                        createMyReqErrorListener()) {
5
6    protected Map<String, String> getParams() throws com.android.volley.AuthFailureError {
7        Map<String, String> params = new HashMap<String, String>();
8        params.put("param1", num1);
9        params.put("param2", num2);
10        return params;
11    };
12};
13queue.add(myReq);
Luca
10 Apr 2017
1public class LoginRequest extends Request<String> {
2
3    // ... other methods go here
4
5    private Map<String, String> mParams;
6
7    public LoginRequest(String param1, String param2, Listener<String> listener, ErrorListener errorListener) {
8        super(Method.POST, "http://test.url", errorListener);
9        mListener = listener;
10        mParams = new HashMap<String, String>();
11        mParams.put("paramOne", param1);
12        mParams.put("paramTwo", param2);
13
14    }
15
16    @Override
17    public Map<String, String> getParams() {
18        return mParams;
19    }
20}