android-volley

Android Volley ImageLoader - BitmapLruCache parameter?

百般思念 提交于 2019-12-17 08:26:07
问题 I am having trouble implementing Image cache using the new Volley library. In the presentation, code look like this mRequestQueue = Volley.newRequestQueue(context); mImageLoader = new ImageLoader(mRequestQueue, new BitmapLruCache()); The BitmapLruCache is obviously not included in the toolkit. Any idea how to implement it or point me to some resources? http://www.youtube.com/watch?v=yhv8l9F44qo @14:38 Thanks! 回答1: import android.graphics.Bitmap; import android.support.v4.util.LruCache; public

How to upload file using Volley library in android?

杀马特。学长 韩版系。学妹 提交于 2019-12-17 06:41:41
问题 I already have a sub class of Request that is used for http post to the server. The problem is, I have no idea on how can I add a parameter for a file. Posting string to the server is easy. but I need to add file as a different parameter. How can I do it? public class AddNewPetRequest extends Request<JSONObject> { private Response.Listener<JSONObject> listener; public AddNewPetRequest(String url, Map<String, String> params, Response.Listener<JSONObject> reponseListener, Response.ErrorListener

How do you use the Android Volley API?

余生颓废 提交于 2019-12-17 05:16:09
问题 I am thinking of implementing the Android Volley library in my next projects (Google IO presentation about Volley). However, I haven't found any serious API for that library. How do I upload files, do POST/GET requests, and add a Gson parser as a JSON parser using Volley? Source code 回答1: Edit: finally here it is an official training about "Volley library" I found some examples about Volley library 6 examples by Ognyan Bankov : Simple request JSON request Gson request Image loading with newer

Android: Volley HTTP Request custom header

萝らか妹 提交于 2019-12-17 05:11:56
问题 I'm getting the following error when I run the app: BasicNetwork.performRequest: Unexpected response code 401 I need to pass an email, a password and a token to access the URL, but it's not working I started learn android last week, I don't know much package quest.testvolley; import com.android.volley.AuthFailureError; import com.android.volley.VolleyLog; import com.kpbird.volleytest.R; import android.app.ProgressDialog; import android.os.Bundle; import android.app.Activity; import android

How does one use Basic Authentication with Volley on Android?

╄→尐↘猪︶ㄣ 提交于 2019-12-17 05:07:22
问题 I'm looking through examples and code but I don't see anything implemented. Is this possible at this stage? 回答1: Yes it's possible. You need to override Request.getHeaders(). I'm lazy and I used HttpHeaders and HttpAuthentication from Spring for Android but you can just build the auth header and return it from the method. From getHeaders() you can return the auth header for basic auth. This is a sample request with basic auth. public class GetUser extends Request<User> { private static final

Does Android Volley support SSL?

两盒软妹~` 提交于 2019-12-17 04:28:19
问题 Does anyone know whether Volley supports SSl in Android? Is there is any way to support SSL via Volley? 回答1: You can refer to my working sample code. Hope this helps! public class MainActivity extends AppCompatActivity { private TextView mTextView; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); mTextView = (TextView) findViewById(R.id.textView); String url = "https://192.168.1.100/testvolley";

Android Volley + JSONObjectRequest Caching

时光毁灭记忆、已成空白 提交于 2019-12-17 04:11:53
问题 public class CustomRequest extends JsonObjectRequest { public CustomRequest(String url, JSONObject params, Listener<JSONObject> listener, ErrorListener errorListener) throws JSONException { super(Method.POST,url, params, listener, errorListener); this.setShouldCache(Boolean.TRUE); } } I was hoping that this piece of code would be enough for me to get implicit caching of responses. I'm not sure if it works or not, because i was under the assumption when a request is sent: it would hit the

Volley - Sending a POST request using JSONArrayRequest

别说谁变了你拦得住时间么 提交于 2019-12-17 03:16:45
问题 I'm using Volley to interact with an API. I need to send a post request (with parameters) to a service that returns a JSON Array. JsonObjectRequest has a constructor that takes a method and a set of parameters JsonObjectRequest(int method, java.lang.String url, JSONObject jsonRequest, Response.Listener<JSONObject> listener, Response.ErrorListener errorListener) However JSONArrayRequest (the one I need) only has one constructor of the form JsonArrayRequest(java.lang.String url, Response

Android set up Volley to use from cache

心已入冬 提交于 2019-12-17 02:10:47
问题 I'm trying to create and use a cache for a server JSON response. For example: cache JSON objects to internal memory and use that when we don't have an internet connection. In the following sample code, I can not find any document about how to cache it with Volley and reuse that when server header for update again don't expire. Like this: set expiration to header and use cache and try to load again after expiration. I'm trying to set cache mechanism for this method: private void

Change Volley timeout duration

末鹿安然 提交于 2019-12-16 20:03:57
问题 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