1

There are similar questions like in the below links but all of them are related with self-signed certificates.

Making a HTTPS request using Android Volley

How can I make Android Volley perform HTTPS request, using a certificate self-signed by an Unkown CA?

In Volley ,Is there any difference between the self-signed or CA signed certificates ?

What is the easiest way for me to make https request to Node server ?

My sample Get request is like;

public static <T> void get(IContext ctx, final Class<T> type, String url, final ServiceResponse callback) {
    String token = LocalStorage.getUserToken(ctx.getContext());

    StringRequest request = new StringRequest(
            Request.Method.GET, url, token,
            new Response.Listener<String>() {

                ServiceResponse _callback = callback;

                @Override
                public void onResponse(String response) {

                    if (type != null) {
                        T result = null;
                        try {

                            result = new ObjectMapper().readValue(response, type);
                        } catch (Exception e) {
                            _callback.onResponse(null, true);
                            return;
                        }

                        _callback.onResponse(result, false);
                    } else {
                        _callback.onResponse(response, false);
                    }
                }
            },
            new Response.ErrorListener() {
                @Override
                public void onErrorResponse(VolleyError error) {
                    callback.onResponse(null, true);
                }
            }
    );
    request.setShouldCache(false);
    request.setRetryPolicy(new DefaultRetryPolicy(
            SOCKET_TIMEOUT_MS,
            MAX_RETRIES,
            BACKOFF_MULT));
    VolleyInstance.getInstance(ctx.getContext()).addToRequestQueue(request);
mhendek
  • 273
  • 2
  • 5
  • 16

0 Answers0