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

i have implemented https by creating new requestQueue in my volley class by the following code public RequestQueue getRequestQueue() { if (mRequestQueue == null) { mRequestQueue = Volley.newRequestQueue(getApplicationContext(), new HurlStack(null, newSslSocketFactory())); } return mRequestQueue; } private SSLSocketFactory newSslSocketFactory() { try { // Get an instance of the Bouncy Castle KeyStore format KeyStore trusted = KeyStore.getInstance(“BKS”); … Read more

Disable Volley cache management

If you use any of the default Request classes implemented in volley(e.g. StringRequest, JsonRequest, etc.), then call setShouldCache(false) right before adding the request object to the volley RequestQueue: request.setShouldCache(false); myQueue.add(request); If you have your own implementation of the Request class, then you can call setShouldCache(false) in the constructor of your class. This solution disables caching … Read more

Android with Gradle (Java finished with non-zero exit value 2)

I think you should change your java JDK change jvm v8 for jdk7. This link can help you: Is it possible to use Java 8 for Android development? Other possible issue its dependency error, clean gradle before build. And change your jackson library for this: compile ‘com.fasterxml.jackson.core:jackson-databind:2.2.+’ compile ‘com.fasterxml.jackson.core:jackson-core:2.2.+’ compile ‘com.fasterxml.jackson.core:jackson-annotations:2.2.+’

How to create a proper Volley Listener for cross class Volley method calling

For your requirement, I suggest you refer to my following solution, hope it’s clear and helpful: First is the interface: public interface VolleyResponseListener { void onError(String message); void onResponse(Object response); } Then inside your helper class (I name it VolleyUtils class): public static void makeJsonObjectRequest(Context context, String url, final VolleyResponseListener listener) { JsonObjectRequest jsonObjectRequest = … Read more

Unexpected response code 500 for POST method

The problem is below. final JsonObjectRequest jsonObjectRequest = new JsonObjectRequest( Method.POST, act.getString(R.string.CommentForUserURL), null, new Response.Listener<JSONObject>() { ^^^^ It should be final JsonObjectRequest jsonObjectRequest = new JsonObjectRequest( Method.POST, act.getString(R.string.CommentForUserURL), new JSONObject(params), new Response.Listener<JSONObject>() { ^^^^^^^^^^^^^^^^^^^^^^ Copy code from protected Map<String, String> getParams() before final JsonObjectRequest. That’s it!!! Reason is as below. The JsonObjectRequest is extended JsonRequest … Read more

Volley – how to send DELETE request parameters?

Same problem here but I found the solution. The problem is the implementation of the createHttpRequest method in com.android.volley.toolbox.HttpClientStack.java which will add the body only if the request method is POST, PUT or PATCH. /** * Creates the appropriate subclass of HttpUriRequest for passed in request. */ @SuppressWarnings(“deprecation”) /* protected */ static HttpUriRequest createHttpRequest(Request<?> request, … Read more

Android Volley POST string in body

To send a normal POST request (no JSON) with parameters like username and password, you’d usually override getParams() and pass a Map of parameters: public void HttpPOSTRequestWithParameters() { RequestQueue queue = Volley.newRequestQueue(this); String url = “http://www.somewebsite.com/login.asp”; StringRequest postRequest = new StringRequest(Request.Method.POST, url, new Response.Listener<String>() { @Override public void onResponse(String response) { Log.d(“Response”, response); } }, … Read more

How to send Authorization header in Android using Volley library?

StringRequest request = new StringRequest(Request.Method.POST, YourUrl, new Response.Listener<String>() { @Override public void onResponse(String response) { if (!response.equals(null)) { Log.e(“Your Array Response”, response); } else { Log.e(“Your Array Response”, “Data Null”); } } }, new Response.ErrorListener() { @Override public void onErrorResponse(VolleyError error) { Log.e(“error is “, “” + error); } }) { //This is for Headers … Read more

How to get and parse a JSON-object with Volley

With your Url, you can use the following sample code: RequestQueue requestQueue = Volley.newRequestQueue(this); String url = “https://itunes.apple.com/search?term=michael+jackson”; JsonObjectRequest jsonObjectRequest = new JsonObjectRequest(url, new Response.Listener<JSONObject>() { @Override public void onResponse(JSONObject response) { if (response != null) { int resultCount = response.optInt(“resultCount”); if (resultCount > 0) { Gson gson = new Gson(); JSONArray jsonArray = response.optJSONArray(“results”); … Read more

How to make separate class for volley library and call all method of volley from another activity and get response?

First create callback interface to get result in Activity public interface IResult { public void notifySuccess(String requestType,JSONObject response); public void notifyError(String requestType,VolleyError error); } Create a separate class with volley function to response the result through interface to activity public class VolleyService { IResult mResultCallback = null; Context mContext; VolleyService(IResult resultCallback, Context context){ mResultCallback = … Read more