android-volley

Change Volley timeout duration

ぃ、小莉子 提交于 2019-12-16 20:01:44
问题 I use the new Volley framework for Android to do a request to my server. But it timeouts before getting the response, although it does respond. I tried adding this code: HttpConnectionParams.setConnectionTimeout(httpParams, 5000); HttpConnectionParams.setSoTimeout(httpParams, timeoutMs); in HttpClientStack of the Volley framework to a different integer (50000), but it still times out before 50 seconds. Is there a way to change the timeout to a long value? 回答1: See Request.setRetryPolicy() and

Scaled images with volley

大兔子大兔子 提交于 2019-12-14 04:27:13
问题 I am trying to stretch images that I load with volley. XML isn't much help, while it can shrink them it doesn't help enlarging them. My exploration of the topic led me to the conclusion that this can be achieved only programmatically. What is my idea ? To extend the volley library and overriding one of the methods, resizing the bitmap right after download and before displaying it. I used this code to resize images that were already on the phone, but this doesn't help me much with random

How to access data outside onResponse?

余生颓废 提交于 2019-12-14 04:12:09
问题 I have no idea why medicine_description is returning null outside onResponse. StringRequest stringRequest = new StringRequest(Request.Method.GET, fda_api + "acetaminophen", new Response.Listener<String>() { @Override public void onResponse(String response) { try { JSONObject json = new JSONObject(response); JSONArray jArray = json.getJSONArray("results"); Log.d(TAG, "readJSON: " + jArray.length()); JSONObject json_data = jArray.getJSONObject(0); medicine_description = json_data.getString(

Volley JsonArrayRequest can not send parameter to Server

依然范特西╮ 提交于 2019-12-14 04:11:12
问题 I have a SearchActivity . i must send a parameter like search keyword to server and receive JsonArray . I used this code for JsonArrayRequest : JsonArrayRequest stringRequest = new JsonArrayRequest(Request.Method.POST, url, new Response.Listener<JSONArray>() { @Override public void onResponse(JSONArray response) { pDialog.dismiss(); Log.e("response : ",response.toString()); } }, new Response.ErrorListener() { @Override public void onErrorResponse(VolleyError volleyError) { pDialog.dismiss();

Out of memory error when use volley library

天大地大妈咪最大 提交于 2019-12-14 03:54:10
问题 i what use ImageView and set images from server, i use Volley library for connect to server and fetch data. but when start Application and scroll items, show FC errors. my items has RecyclerView , CardView and custom ImageView . My Adapter codes : public class DataAdapter extends RecyclerView.Adapter { private final int VIEW_ITEM = 1; private final int VIEW_PROG = 0; private List<newSMS_class> sms_list; private int visibleThreshold = 5; private int lastVisibleItem, totalItemCount; private

Android RequestQueue not initialized

倖福魔咒の 提交于 2019-12-14 03:24:15
问题 I am new to android and currently I want to develop an application that need to request network using volley. However, it returns error below: Caused by: java.lang.IllegalStateException: RequestQueue not initialized at com.myapp.zeptomobile.myapp.app.StaggeredDemoApplication.getRequestQueue(StaggeredDemoApplication.java:35) at com.myapp.zeptomobile.myapp.FlickrActivity.onCreate(FlickrActivity.java:75) at android.app.Activity.performCreate(Activity.java:5248) at android.app.ActivityThread

Json data array request keeps skipping onResponse

北战南征 提交于 2019-12-14 02:29:24
问题 I keep trying to look up and find a solution for my problem. I am populating a Spinner with json data from a URL , the Json data is nameless and I'm trying to get the data into an ArrayList so I can populate the Spinner . Whenever I debug I can see that it skips my onResponse() method after making either StringRequest or JSONArrayRequest , Please look at my code and see what am I doing wrong yearsp.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { @Override public void

How to use volley library for network call using Socket(IP address) and port number(eg. 1234)?

你说的曾经没有我的故事 提交于 2019-12-13 21:48:41
问题 I want to send byte [] to make a request and in the response i will get the byte[].So can you please help me. Right now i am using the Asynctask doInBackground() for the network call and Socket class. Had gone through some link but could not found the solution. Thanks in advance. 回答1: Seems Volley is a http library, see this. It's good enough to use AsyncTask for this. Edit Kryonet is another very good Java network library for sending TCP and UDP packets over network efficiently which runs on

How to send a multipart request in Android with Volley

大兔子大兔子 提交于 2019-12-13 20:04:28
问题 I have some code to send multipart request with Android Volley. But When i'm try running the code, showing error "BasicNetwork.performRequest: Unexpected response code 401". Hope, anyone can help me. Thanks. This My Multipartrequest. public class MultipartRequest extends Request<String> { MultipartEntityBuilder entity = MultipartEntityBuilder.create(); HttpEntity httpentity; private String FILE_PART_NAME = "upload"; private final Response.Listener<String> mListener; private final File

how to access restful web service methods using volley library

雨燕双飞 提交于 2019-12-13 18:51:47
问题 I have created a restful web service using this tutorial http://www.tutecentral.com/restful-api-for-android-part-1/ after running this i got an auto generated java file which contains the following code. public class RestAPI { private final String urlString = "http://125.0.0.174/Handler1.ashx"; private static String convertStreamToUTF8String(InputStream stream) throws IOException { String result = ""; StringBuilder sb = new StringBuilder(); try { InputStreamReader reader = new