android-volley

BasicNetwork.performRequest - Unexpected response code 400 (POST)

六月ゝ 毕业季﹏ 提交于 2019-12-12 16:36:13
问题 When I am trying to fetch data through rest api using Volley StringRequest or JsonObjectRequest. I always get 400 error. Its working fine with the postman. Http request method is POST, Content-Type is application/x-www-form-urlencoded. I have also checked my parameter spelling and it looks fine to me. I have tried with both StringRequest and JsonObjectRequest, result is E/Volley: [10283] BasicNetwork.performRequest: Unexpected response code 400. Below is my code. I have attached a screenshot.

Volley disable cache for one request

夙愿已清 提交于 2019-12-12 12:26:42
问题 I want to use the default cache policy of volley for all my requests except one . Is this possible? I would like to get the response from internet every time this request is called. Thank's in advance ! 回答1: You can easily disable cache for a particular request by changing the method com.android.volley.toolbox.HttpHeaderParser.parseCacheHeaders(NetworkResponse response) and ignore these headers, set entry.softTtl and entry.ttl fields to whatever value works for you and use your method in your

Android-Volley : set HTTP Header for JsonArrayRequest

ぃ、小莉子 提交于 2019-12-12 10:53:49
问题 so I've seen a couple of examples for JsonObjectRequests where either this code has been added @Override public String getBodyContentType() { return "application/json"; } and sometimes this Code has been used @Override public Map<String, String> getHeaders() throws AuthFailureError { HashMap<String, String> headers = new HashMap<String, String>(); headers.put("Content-Type", "application/json"); return headers; } either way, it has always been used in combination with a JsonObjectRequest. I

Android: Cancel Volley request during execution due to slow connection

邮差的信 提交于 2019-12-12 10:16:52
问题 I'm using Volley in Android in order to make requests including fetching relatively large amount of data. I want to make timer of 5 seconds and if after it the request not returned - it probably means that there is slow connection and therefore I want to cancel the request. So far what I did: Timer timer = new Timer(); VioozerVolleyRequestFactory mFactory = new VioozerVolleyRequestFactory(this); RequestQueue mQueue = VioozerVolleySingleton.getInstance(this).getRequestQueue(); timer.schedule

No peer certificate Exception - Volley and Android with self signed certificate

非 Y 不嫁゛ 提交于 2019-12-12 08:48:44
问题 I'm trying to make my app communicate with my server via https. As I don't want to pay to get my server certificate signed by a trusted CA, the solution is to use a self signed certificate. So, I've created my caconfig.cnf as follows: [ ca ] default_ca = CA_default # The default ca section [ CA_default ] dir = ./demoCA # top dir database = $dir/index.txt # index file. new_certs_dir = $dir/newcerts # new certs dir certificate = $dir/cacert.pem # The CA cert serial = $dir/serial # serial no

Android Volley access http response header fields

戏子无情 提交于 2019-12-12 08:27:52
问题 How can i access HTTP header fields like ETag from a response using Volley ? With HttpUrlCoonection i just do conn.getHeaderField("ETag") and that's it. Thanks 回答1: You can subclass Request (or any of its subclasses) and override the parseNetworkResponse method: @Override protected Response<Bitmap> parseNetworkResponse(NetworkResponse response) { Map<String, String> responseHeaders = response.headers; } 回答2: You can extend Request class. Then when you implement parseNetworkResponse

Post Json object data to get Json array response using volley in android

时光怂恿深爱的人放手 提交于 2019-12-12 07:47:45
问题 I need to post JSONObject (using Volley ) to a web-service which is returning the response in JSONArray format. Here is what I have tried so far. final JSONObject requestJsonObject = new JSONObject(); requestJsonObject.put("username", userName); requestJsonObject.put("password", password); JsonObjectRequest jsonObjReq = new JsonObjectRequest(Method.POST, ServiceUrls.LOGIN_URL, requestJsonObject, loginResponseListener, loginErrorListener); private Listener<JSONObject> loginResponseListener =

App works on WIFI but not on 3G

☆樱花仙子☆ 提交于 2019-12-12 07:37:48
问题 There are two activities: Main and Detail Activity. Main Activity is basically a GridView. Detail Activity is basically shows the clicked item's detail information. I am passing selected item's id ( pid ) from the Main to the Detail Activity. I am facing an issue as follows. Initially, I have 3G connection (cellular connection) and clicked on the first item and see the corresponding item detail in the Detail Activity , it works perfectly fine, and go back to the Main Activity , then clicked

How to optimize network-queue-take in android Volley? (Volley Google IO 2013)

与世无争的帅哥 提交于 2019-12-12 07:09:43
问题 Below is a snapshot of the Volley logs for an image request. Almost half of the rendering time is due to network-queue-take. Another one is even more dramatically high, the bulk of the time being in the network-queue-take. How can this be optimized so that network-queue-take is faster? What determines (other than thread priority, image requests are by default LOW priority requests), the speed of the network-queue-take? Note: I ran this on Samsung Galaxy S4. 08-07 11:01:09.560: D/Volley(938):

Android Volley - can't do a JSON request with POST, getting empty response

旧巷老猫 提交于 2019-12-12 06:58:24
问题 I am trying to make a json request using Volley library to a php server, but for some reason the server does not receive the json object I am sending, and it responds with empty string. Here is my code import android.content.Context; import com.android.volley.Request; import com.android.volley.RequestQueue; import com.android.volley.Response.Listener; import com.android.volley.Response.ErrorListener; import com.android.volley.VolleyError; import com.android.volley.toolbox.JsonObjectRequest;