android-volley

Why Volley DiskBasedCache splicing without direct access to the cache file name

↘锁芯ラ 提交于 2019-12-30 10:47:11
问题 /** * Creates a pseudo-unique filename for the specified cache key. * * @param key The key to generate a file name for. * @return A pseudo-unique filename. */ private String getFilenameForKey(String key) { int firstHalfLength = key.length() / 2; String localFilename = String.valueOf(key.substring(0, firstHalfLength).hashCode()); localFilename += String.valueOf(key.substring(firstHalfLength).hashCode()); return localFilename; } This code from Google Volley DiskBasedCache . Why splicing without

Android Volley post json data to server

送分小仙女□ 提交于 2019-12-30 07:09:06
问题 I am new in Java. I want to send post json data to webserver. My Volley post is given below. public void postData(String url,JSONObject data,final VolleyCallback mResultCallback){ RequestQueue requstQueue = Volley.newRequestQueue(mContext); JsonObjectRequest jsonobj = new JsonObjectRequest(Request.Method.POST, url,null, new Response.Listener<JSONObject>() { @Override public void onResponse(JSONObject response) { if(mResultCallback != null){ mResultCallback.notifySuccess(response); } } }, new

How do I use the Volley network request queue?

人盡茶涼 提交于 2019-12-30 04:44:07
问题 I .add( new network calls to my Volley Request Queue which I have created as a singleton as suggested. But I always immediately .start() these network calls. This is always done as an action in an activity or a fragment. The add method cannot even be chained into a start method, like .add(new volley request).start() So this assumes I am actually managing (or wanting to manage) a network queue somewhere, outside of the way Volley handles its queue, I guess. Should I be sending these things to

How to get error message description using Volley

一曲冷凌霜 提交于 2019-12-30 04:38:21
问题 I'm sending an http request from Android Java using the Volley library to a c# backend. The backend application responds with a error code and description as intended, as well as a StatusDescription. I can see the response status description through wireshark but do not know how to get the description string on the android side. final JsonObjectRequest request = new JsonObjectRequest(JsonObjectRequest.Method.POST, url,json, new Response.Listener<JSONObject>() { @Override public void

Volley SSL - Hostname was not verified

主宰稳场 提交于 2019-12-30 03:33:10
问题 I'm developing an Android App and I need to access an HTTPS address. I'm using Volley to request my data, but now i'm getting this error com.android.volley.NoConnectionError: java.io.IOException: Hostname '<address>' was not verified To get the SSL factory i make this: private static SSLSocketFactory getSocketFactory() { SSLSocketFactory socketFactory = null; try { final CertificateFactory certificateFactory = CertificateFactory.getInstance("X.509"); final BufferedInputStream bis = new

Cannot convert java.lang.string into json object

孤人 提交于 2019-12-29 08:24:46
问题 This project is about login where i am trying to login and getting this error.Cannot convert json obj to java.lang . String what should i do to resolve this error? i am getting an error in json object even when i was passing a string value now i change the string value to exact same value where i was getting an error . I have tried many things to resolve it by making a string object and then passing it instead of response But it then showed an error cannot expect a literal value ay character

StringRequest with JSON body

ⅰ亾dé卋堺 提交于 2019-12-29 07:48:09
问题 I'm trying to send a request using Volley but I can't figure how to make it work. I need to send a POST request with JSON encoded data as the body, but after hours of trying different things I still can't make it work. This is my current code for the request: User user = User.getUser(context); String account = user.getUserAccount(); String degreeCode = user.getDegreeCode(); final JSONObject body = new JSONObject(); try { body.put(NEWS_KEY, 0); body.put(NEWS_DEGREE, degreeCode); body.put(NEWS

Put ArrayList into param JsonObject

拜拜、爱过 提交于 2019-12-29 07:46:28
问题 i must do i request with Volley Framework. This is a POST request with JSONObject. I must pass one string and one JSONArray..but how i can? I start with this: private String mUrl; private ArrayList<String> mUrlDove; HashMap<String, String> params = new HashMap<String, String>(); params.put("url", mUrl); params.put("urlDove", mUrlDove); ---> Wrong because mUrlDove is not a String mUrl = app.getInstance().getmUrlRestWS() + getString(R.string.path); JsonObjectRequest mRequest = new

UTF-8 encoding in Volley Requests

為{幸葍}努か 提交于 2019-12-29 05:20:09
问题 In my Android app I am loading json data with a Volley JsonArrayRequest . The data were created by myself and I saved them with Sublime with UTF-8 encoding. When I get the Response and fill my ListView , the texts are not displayed correctly (umlauts). This is what my Request looks like: JsonArrayRequest request = new JsonArrayRequest(targetUrl, new Response.Listener<JSONArray>() { @Override public void onResponse(final JSONArray response) { try { fillList(response); } catch (JSONException e)

how to send authorization header in android using volley library

落爺英雄遲暮 提交于 2019-12-28 13:37:53
问题 how to send Authorization header using volley library in android for GET method please help me thank you JsonObjectRequest req = new JsonObjectRequest(Request.Method.GET, url, null, new Response.Listener<JSONObject>() { @Override public void onResponse(JSONObject response) { Log.d("Response", response.toString()); pd.dismiss(); Toast.makeText(MainActivity.this, "" + response.toString(), Toast.LENGTH_SHORT).show(); } }, new Response.ErrorListener() { @Override public void onErrorResponse