Volley is an HTTP library that makes networking for Android apps easier and, most importantly, faster.
For more information about Volley and how to use it, visit the documentation page.
Home Page: https://google.github.io/volley
License: Apache License 2.0
Volley is an HTTP library that makes networking for Android apps easier and, most importantly, faster.
For more information about Volley and how to use it, visit the documentation page.
Previous discussion: https://groups.google.com/forum/#!topic/volley-users/rNTlV-LORzY
The main use case here seems to be server responses with multiple Set-Cookie headers. It looks like a valid feature request, but the concern is that this would require breaking the public API.
Hello,
I want to use multipart request in my project which is using Volley. Can you please guide how can I use multipart request to upload file image/video.
Thanks,
Volley currently depends on Apache HTTP. We can mostly remove the dependency except that HttpStack#performRequest returns an org.apache.http.HttpResponse, which means it'd be an API-breaking change to remove.
It might be worth biting the bullet and just doing a major version bump that breaks the API. There are other known issues that we could potentially address alongside this. However, one avenue worth exploring would be to see if we could treat Apache HTTP as a "provided" dependency - that is, one which is available at compile time, but not runtime - and then deprecate the old performRequest and add a new one that is implemented by all built-in clients (except HttpClientStack, which should be deprecated as well).
I think the result would compile and let apps build against Volley without pulling in the Apache HTTP dependency, but existing users could continue to use the Apache stack as long as they pulled in the dependency at runtime (and it should be there on an actual Android device).
Apart from the ugliness, my main concern is how proguard would respond to the missing reference - we could add a consumer proguard rule to not warn on org.apache stuff though that might be a bit overbearing.
Pending change in AOSP: https://android-review.googlesource.com/#/c/137020/
Looks like this was probably good cleanup, so should look into taking this change over and merging it.
java.lang.NegativeArraySizeException: -557
at com.android.volley.toolbox.DiskBasedCache.streamToBytes(DiskBasedCache.java:323)
at com.android.volley.toolbox.DiskBasedCache.get(DiskBasedCache.java:119)
at com.android.volley.CacheDispatcher.run(CacheDispatcher.java:100)
This is my stacktrace. I think it's caused by unhandled NullPointer in the CacheDispatcher. My app crashs with this stacktrace everytime when the OS cleans up the Volley cache.
Javadoc specs have changed and compilation fails with the following issues with java 8
C:\Repos\Volley\volley\src\main\java\com\android\volley\toolbox\BasicNetwork.java:268: error: malformed HTML
* Converts Headers[] to Map.
^
C:\Repos\Volley\volley\src\main\java\com\android\volley\toolbox\BasicNetwork.java:268: error: bad use of '>'
* Converts Headers[] to Map.
^
C:\Repos\Volley\volley\src\main\java\com\android\volley\VolleyLog.java:40: error: self-closing element not allowed
*
^
C:\Repos\Volley\volley\src\main\java\com\android\volley\VolleyLog.java:42: error: self-closing element not allowed
*
^
C:\Repos\Volley\volley\src\main\java\com\android\volley\VolleyLog.java:28: error: self-closing element not allowed
*
^
C:\Repos\Volley\volley\src\main\java\com\android\volley\VolleyLog.java:29: error: self-closing element not allowed
* to see Volley logs call:
^
In volley, to finish a thread such as CacheDiapatcher and NetworkDispatcher, are inturrupt not enough? Whether need the mQuit variable necessarily.
If write like this, hava any problems? those thread can be interrupted in other scenes?
public void quit() { interrupt(); }
while (!isInterrupted()) { ................... try { request = mQueue.take(); } catch (InterruptedException e) { return; } }
BasicNetwork.performRequest()
makes some decisions about when to retry and when not to that I would like to be able to change, either in a RetryPolicy
implementation or in the ErrorListener
. For my application, it makes sense to retry on NetworkError
and ServerError
, with an exponential backoff.
I'd prefer not to have to implement a custom Network
implementation for this. The best thing would be to be able to do it from the ErrorListener
. But that's only passed the error at the moment, not the request. There's also no good way I can see to put the request back in the queue as a retry - by the time the ErrorListener
is called, the request is out of the queue.
What should I do?
I have a RecyclerView with HEADER and ITEM to be populated from two separate URL JSON responses, how to approach this:
but this is only for dummy data.
Or is this possible to embed a Volley request inside of another Volley request so that
adapter = new SimpleItemRecyclerViewAdapter(resHeader, resultItems);
are ready to be processed
Thanks
ImageRequest.java
has Priority.LOW
by default. There is no any easy way to load images with different priority. The only way currently is to implement own ImageLoader
and extend ImageRequest.java
to support other priorities. I think that ability to have different Priorities for Images loading. Let me know if you are agree and I may work on a patch, since I already have this feature added to valley for my project.
FATAL EXCEPTION: main Process: in.publicam.cricsquad, PID: 7283
java.lang.IllegalStateException: Marker added to finished log
at com.android.volley.VolleyLog$MarkerLog.add(VolleyLog.java:132)
at com.android.volley.Request.finish(Request.java:240)
at com.android.volley.ExecutorDelivery$ResponseDeliveryRunnable.run(ExecutorDelivery.java:109)
Lenovo a7000 Marshmallow OS
After the activity was destroyed, I called the cannel method, but listener was still leaking
http://blog.csdn.net/wangshihui512/article/details/51249048
I'm in the same position as this address, but the solution isn't good because it doesn't automatically cache offline.
Currently volley doesn't support gzip decompression. There is a lot of different implementations based on GZIPInputStream
in internet. Shouldn't this be a part of API and be available by default?
I want to remove retry from volley. I dont want to set any retry policy as it sends duplicate request to the server
hi, how to send request and get response cookies using volley?
this is my function
public void doActionJsonPost() {
// Request a string response from the provided URL.
StringRequest stringRequest = new StringRequest(Request.Method.POST, IConstants.BASE_URL + url,
new Response.Listener<String>() {
@Override
public void onResponse(String response) {
JSONObject jsonObject;
try {
jsonObject = new JSONObject(response);
String msgCode = jsonObject.getString("responseCode");
} catch (JSONException e) {
LoggingHelper.verbose(e.toString());
iHttpAsync.onAsyncFailed(e.toString());
} catch (Exception e) {
LoggingHelper.verbose(e.toString());
iHttpAsync.onAsyncFailed(e.toString());
}
}
},
new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError error) {
LoggingHelper.verbose("ERROR");
iHttpAsync.onAsyncFailed(error.getMessage());
}
}){
@Override
public byte[] getBody() throws AuthFailureError {
iHttpAsync.onAsyncProgress();
return parameters.getBytes();
}
@Override
public String getBodyContentType() {
return "application/json";
}
@Override
public Map<String, String> getHeaders() throws AuthFailureError {
return getAuthHeader(context);
}
@Override
protected Response<String> parseNetworkResponse(NetworkResponse response) {
Map<String, String> responseHeaders = response.headers;
String rawCookies = responseHeaders.get("Set-Cookie");
return super.parseNetworkResponse(response);
}
};
RequestQueue requestQueue = Volley.newRequestQueue(context);
requestQueue.add(stringRequest);
}
i've overriden parseNetworkResponse to get header, but there is no cookies in the header
how can I get and set cookie with volley?
I have spend hours and hours on this issue to find perfect solution and I found that Volley should have a function which return HttpUrlConnection (For example getConnection()
)so it will be very helpful for developers to customize library and be able to use standard HttpUrlConnection ways like below:
For example to get response headers
Map<String, List<String>> headerFields = connection.getHeaderFields();
List<String> cookiesHeader = headerFields.get(COOKIES_HEADER);
if(cookiesHeader!=null){
if (cookiesHeader != null) {
for (String cookie : cookiesHeader) {
Log.i("info",cookie);
msCookieManager.getCookieStore().add(null, HttpCookie.parse(cookie).get(0));
}
}
}
static void writeString(OutputStream os, String s) throws IOException {
byte[] b = s.getBytes("UTF-8");
writeLong(os, b.length);
os.write(b, 0, b.length);
}
static String readString(InputStream is) throws IOException {
int n = (int) readLong(is);
byte[] b = streamToBytes(is, n);
return new String(b, "UTF-8");
}
When I try to send a request, it seems to do absolutely nothing, and the callback is never called.
It also prints this in the logcat:
I/System.out (HTTPLog)-Static: isSBSettingEnabled false
I/System.out (HTTPLog)-Static: isSBSettingEnabled false
I/qtaguid Tagging socket 36 with tag 7dbc04b800000000{2109473976,0} for uid -1, pid: 7750, getuid(): 10553
I/qtaguid Untagging socket 36
Apparently, I read that this occurs on Samsung devices, and I am indeed on a Galaxy A3. What's very strange is that this bug started at a random moment, after removing a few things from my code that have absolutely nothing to do with internet (animations). I have tried reinstalling my app, cleaning the data/cache, rebooting my phone but nothing worked.
I am getting this error when making a POST request when connected to mobile data network:
{"statusCode":"com.android.volley.NoConnectionError: java.net.SocketException: socket failed: errno 64 (Machine is not on the network)"}
I am working on a project where I want to write my own implementation of ResponseDelivery
. As part of handling the delivery, it looks like (based on the behavior of ExecutorDelivery) I should be calling Request.finish
, but I can't do that because the method is package private.
I don't see anything to indicate that the method is supposed to be package private. Is it supposed to be, or was the access modifier omitted by mistake?
Hi
I wonder if there any intention to support kotlin by making volley code full kotlin instead of java?
Thanks
In my app RESTful services are called in background threading & in 1 sec i want tom kae 2 to 4 request in one thread…And there may be 3 to 4 such thread running in parallel & making individual REST request…
So in this Situation which lib. should I use ??
Plz help me out..
Thanks…
DiskBasedCache may fail repeatedly if a cached header is corrupt. In the event of failure, the most common error is OutOfMemoryError thrown from streamToBytes, caused by trying to allocate a huge number of bytes resulting from the bogus length calculated due to the corruption.
Once a header has been corrupt, the cache initialization will continue to fail, and the errant header will not be removed.
A less common failure was NegativeArraySizeException, but that was recently patched.
DiscBasedCache needs to be updated to guard against corruption.
Related to:
https://code.google.com/p/android/issues/detail?id=230219
mcxiaoke/android-volley#141 (mirror)
http://stackoverflow.com/a/42196956/901597
Hi, I was going to through the code on the retry mechanism today and came across the RetryPolicy. The following code is from the class DefaultRetryPolicy.
/**
* Prepares for the next retry by applying a backoff to the timeout.
* @param error The error code of the last attempt.
*/
@Override
public void retry(VolleyError error) throws VolleyError {
mCurrentRetryCount++;
mCurrentTimeoutMs += (mCurrentTimeoutMs * mBackoffMultiplier);
if (!hasAttemptRemaining()) {
throw error;
}
}
Under the circumstance where the NetworkDispatcher wants to retry a request, it calls retry() on the RetryPolicy instance of that request. I would assume that the same request should be added to the RequestQueue as an retry attempt.
But the retry() method actually doesn't do much other than updating a few values, which doesn't schedule another call to fire the failed request again.
If we look at the test case in BasicNetworkTest, it seems that we should assume that a retry request has been made as long as the retry() method of the RetryPolicy instance is called. But the currently implementation of DefaultRetryPolicy doesn't really do that.
@Test public void serverError_enableRetries() throws Exception {
for (int i = 500; i <= 599; i++) {
MockHttpStack mockHttpStack = new MockHttpStack();
BasicHttpResponse fakeResponse =
new BasicHttpResponse(new ProtocolVersion("HTTP", 1, 1), i, "");
mockHttpStack.setResponseToReturn(fakeResponse);
BasicNetwork httpNetwork =
new BasicNetwork(mockHttpStack, new ByteArrayPool(4096));
Request<String> request = buildRequest();
request.setRetryPolicy(mMockRetryPolicy);
request.setShouldRetryServerErrors(true);
doThrow(new VolleyError()).when(mMockRetryPolicy).retry(any(VolleyError.class));
try {
httpNetwork.performRequest(request);
} catch (VolleyError e) {
// expected
}
// should retry all 500 errors
verify(mMockRetryPolicy).retry(any(ServerError.class));
reset(mMockRetryPolicy);
}
}
Forking from #52 (comment):
Some parts of DiskBasedCache use the file size as the size of the cache entry, which includes the header overhead. Other parts use the data size which doesn't include the header overhead.
We should make this sane. Some constraints:
device specs:
Infinix X509
android:5.1
volley version 1.0.0
java.util.concurrent.TimeoutException: com.android.volley.toolbox.PoolingByteArrayOutputStream.finalize() timed out after 10 seconds
at com.android.volley.toolbox.ByteArrayPool.returnBuf(ByteArrayPool.java:111)
at com.android.volley.toolbox.PoolingByteArrayOutputStream.finalize(PoolingByteArrayOutputStream.java:65)
at java.lang.Daemons$FinalizerDaemon.doFinalize(Daemons.java:191)
at java.lang.Daemons$FinalizerDaemon.run(Daemons.java:174)
at java.lang.Thread.run(Thread.java:818)
in oppo x9007:
After some time the phone crashes;
Cmd line: com.esbook.reader
JNI: CheckJNI is off; workarounds are on; pins=1; globals=160
DALVIK THREADS:
(mutexes: tll=0 tsl=0 tscl=0 ghl=0)
"main" prio=5 tid=1 NATIVE
| group="main" sCount=1 dsCount=0 obj=0x41ee9710 self=0x41ed4b00
| sysTid=11799 nice=0 sched=0/0 cgrp=apps handle=1074655228
| state=S schedstat=( 167869122 72698117 339 ) utm=14 stm=2 core=0
#00 pc 0001c8bc /system/lib/libc.so (epoll_wait+12)
#1 pc 00014ff1 /system/lib/libutils.so (android::Looper::pollInner(int)+92)
#2 pc 00015215 /system/lib/libutils.so (android::Looper::pollOnce(int, int*, int*, void**)+92)
#3 pc 0006baf5 /system/lib/libandroid_runtime.so (android::NativeMessageQueue::pollOnce(_JNIEnv*, int)+22)
#4 pc 000203cc /system/lib/libdvm.so (dvmPlatformInvoke+112)
#5 pc 00050ca7 /system/lib/libdvm.so (dvmCallJNIMethod(unsigned int const*, JValue*, Method const*, Thread*)+398)
#6 pc 00029860 /system/lib/libdvm.so
#7 pc 0002e218 /system/lib/libdvm.so (dvmInterpret(Thread*, Method const*, JValue*)+184)
#8 pc 00062fbf /system/lib/libdvm.so (dvmInvokeMethod(Object*, Method const*, ArrayObject*, ArrayObject*, ClassObject*, bool)+350)
#9 pc 0006abe3 /system/lib/libdvm.so
#10 pc 00029860 /system/lib/libdvm.so
#11 pc 0002e218 /system/lib/libdvm.so (dvmInterpret(Thread*, Method const*, JValue*)+184)
#12 pc 00062d01 /system/lib/libdvm.so (dvmCallMethodV(Thread*, Method const*, Object*, bool, JValue*, std::__va_list)+292)
#13 pc 0004c88b /system/lib/libdvm.so
#14 pc 0004f53b /system/lib/libandroid_runtime.so
#15 pc 000501cb /system/lib/libandroid_runtime.so (android::AndroidRuntime::start(char const*, char const*)+378)
#16 pc 0000105b /system/bin/app_process
#17 pc 0000df77 /system/lib/libc.so (__libc_init+50)
#18 pc 00000d7c /system/bin/app_process
at android.os.MessageQueue.nativePollOnce(Native Method)
at android.os.MessageQueue.next(MessageQueue.java:132)
at android.os.Looper.loop(Looper.java:124)
at android.app.ActivityThread.main(ActivityThread.java:5166)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:525)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:768)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:584)
at dalvik.system.NativeStart.main(Native Method)
"java.lang.ProcessManager" daemon prio=5 tid=24 NATIVE
| group="main" sCount=1 dsCount=0 obj=0x431ca018 self=0x74367ec8
| sysTid=11857 nice=0 sched=0/0 cgrp=apps handle=1949690488
| state=S schedstat=( 236354 672136 7 ) utm=0 stm=0 core=0
#00 pc 0001afd8 /system/lib/libc.so (wait4+8)
#1 pc 00021b33 /system/lib/libjavacore.so
#2 pc 000203cc /system/lib/libdvm.so (dvmPlatformInvoke+112)
#3 pc 00050ca7 /system/lib/libdvm.so (dvmCallJNIMethod(unsigned int const*, JValue*, Method const*, Thread*)+398)
#4 pc 00029860 /system/lib/libdvm.so
#5 pc 0002e218 /system/lib/libdvm.so (dvmInterpret(Thread*, Method const*, JValue*)+184)
#6 pc 00062d01 /system/lib/libdvm.so (dvmCallMethodV(Thread*, Method const*, Object*, bool, JValue*, std::__va_list)+292)
#7 pc 00062d2b /system/lib/libdvm.so (dvmCallMethod(Thread*, Method const*, Object*, JValue*, ...)+20)
#8 pc 00057aa3 /system/lib/libdvm.so
#9 pc 0000cde0 /system/lib/libc.so (__thread_entry+72)
#10 pc 0000cf5c /system/lib/libc.so (pthread_create+208)
at libcore.io.Posix.waitpid(Native Method)
at libcore.io.ForwardingOs.waitpid(ForwardingOs.java:141)
at java.lang.ProcessManager.watchChildren(ProcessManager.java:86)
at java.lang.ProcessManager.access$000(ProcessManager.java:40)
at java.lang.ProcessManager$1.run(ProcessManager.java:58)
"Thread-1362" prio=5 tid=25 NATIVE
| group="main" sCount=1 dsCount=0 obj=0x431c8718 self=0x7436b2f0
| sysTid=11856 nice=0 sched=0/0 cgrp=apps handle=1949707288
| state=S schedstat=( 17581453 7506511 99 ) utm=0 stm=1 core=2
#00 pc 0001b4b0 /system/lib/libc.so (read+8)
#1 pc 00021d91 /system/lib/libjavacore.so
#2 pc 000203cc /system/lib/libdvm.so (dvmPlatformInvoke+112)
#3 pc 00050ca7 /system/lib/libdvm.so (dvmCallJNIMethod(unsigned int const*, JValue*, Method const*, Thread*)+398)
#4 pc 00029860 /system/lib/libdvm.so
#5 pc 0002e218 /system/lib/libdvm.so (dvmInterpret(Thread*, Method const*, JValue*)+184)
#6 pc 00062fbf /system/lib/libdvm.so (dvmInvokeMethod(Object*, Method const*, ArrayObject*, ArrayObject*, ClassObject*, bool)+350)
#7 pc 0006abe3 /system/lib/libdvm.so
#8 pc 00029860 /system/lib/libdvm.so
#9 pc 0002e218 /system/lib/libdvm.so (dvmInterpret(Thread*, Method const*, JValue*)+184)
#10 pc 00062d01 /system/lib/libdvm.so (dvmCallMethodV(Thread*, Method const*, Object*, bool, JValue*, std::__va_list)+292)
#11 pc 00062d2b /system/lib/libdvm.so (dvmCallMethod(Thread*, Method const*, Object*, JValue*, ...)+20)
#12 pc 0007063f /system/lib/libdvm.so
#13 pc 00029860 /system/lib/libdvm.so
#14 pc 0002e218 /system/lib/libdvm.so (dvmInterpret(Thread*, Method const*, JValue*)+184)
#15 pc 00062d01 /system/lib/libdvm.so (dvmCallMethodV(Thread*, Method const*, Object*, bool, JValue*, std::__va_list)+292)
#16 pc 00062d2b /system/lib/libdvm.so (dvmCallMethod(Thread*, Method const*, Object*, JValue*, ...)+20)
#17 pc 00057aa3 /system/lib/libdvm.so
#18 pc 0000cde0 /system/lib/libc.so (__thread_entry+72)
#19 pc 0000cf5c /system/lib/libc.so (pthread_create+208)
at libcore.io.Posix.readBytes(Native Method)
at libcore.io.Posix.read(Posix.java:127)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:525)
at com.morgoo.droidplugin.hook.proxy.ProxyHook.invoke(ProxyHook.java:56)
at $Proxy17.read(Native Method)
at libcore.io.BlockGuardOs.read(BlockGuardOs.java:149)
at libcore.io.IoBridge.read(IoBridge.java:425)
at java.io.FileInputStream.read(FileInputStream.java:179)
at java.io.InputStreamReader.read(InputStreamReader.java:244)
at java.io.BufferedReader.fillBuf(BufferedReader.java:130)
at java.io.BufferedReader.readLine(BufferedReader.java:354)
at com.esbook.reader.util.LogcatHelper$LogDumper.run(LogcatHelper.java:112)
"DroidPlugin@FileLogThread" prio=5 tid=23 NATIVE
| group="main" sCount=1 dsCount=0 obj=0x43178748 self=0x74361bc8
| sysTid=11849 nice=0 sched=0/0 cgrp=apps handle=1949695016
| state=S schedstat=( 232396 175416 1 ) utm=0 stm=0 core=2
#00 pc 0001c8bc /system/lib/libc.so (epoll_wait+12)
#1 pc 00014ff1 /system/lib/libutils.so (android::Looper::pollInner(int)+92)
#2 pc 00015215 /system/lib/libutils.so (android::Looper::pollOnce(int, int*, int*, void**)+92)
#3 pc 0006baf5 /system/lib/libandroid_runtime.so (android::NativeMessageQueue::pollOnce(_JNIEnv*, int)+22)
#4 pc 000203cc /system/lib/libdvm.so (dvmPlatformInvoke+112)
#5 pc 00050ca7 /system/lib/libdvm.so (dvmCallJNIMethod(unsigned int const*, JValue*, Method const*, Thread*)+398)
#6 pc 00029860 /system/lib/libdvm.so
#7 pc 0002e218 /system/lib/libdvm.so (dvmInterpret(Thread*, Method const*, JValue*)+184)
#8 pc 00062d01 /system/lib/libdvm.so (dvmCallMethodV(Thread*, Method const*, Object*, bool, JValue*, std::__va_list)+292)
#9 pc 00062d2b /system/lib/libdvm.so (dvmCallMethod(Thread*, Method const*, Object*, JValue*, ...)+20)
#10 pc 00057aa3 /system/lib/libdvm.so
#11 pc 0000cde0 /system/lib/libc.so (__thread_entry+72)
#12 pc 0000cf5c /system/lib/libc.so (pthread_create+208)
at android.os.MessageQueue.nativePollOnce(Native Method)
at android.os.MessageQueue.next(MessageQueue.java:132)
at android.os.Looper.loop(Looper.java:124)
at android.os.HandlerThread.run(HandlerThread.java:61)
"LocationClient" prio=5 tid=22 NATIVE
| group="main" sCount=1 dsCount=0 obj=0x43111aa8 self=0x7435cf00
| sysTid=11843 nice=0 sched=0/0 cgrp=apps handle=1949684560
| state=S schedstat=( 249688 0 3 ) utm=0 stm=0 core=2
#00 pc 0001c8bc /system/lib/libc.so (epoll_wait+12)
#1 pc 00014ff1 /system/lib/libutils.so (android::Looper::pollInner(int)+92)
#2 pc 00015215 /system/lib/libutils.so (android::Looper::pollOnce(int, int*, int*, void**)+92)
#3 pc 0006baf5 /system/lib/libandroid_runtime.so (android::NativeMessageQueue::pollOnce(_JNIEnv*, int)+22)
#4 pc 000203cc /system/lib/libdvm.so (dvmPlatformInvoke+112)
#5 pc 00050ca7 /system/lib/libdvm.so (dvmCallJNIMethod(unsigned int const*, JValue*, Method const*, Thread*)+398)
#6 pc 00029860 /system/lib/libdvm.so
#7 pc 0002e218 /system/lib/libdvm.so (dvmInterpret(Thread*, Method const*, JValue*)+184)
#8 pc 00062d01 /system/lib/libdvm.so (dvmCallMethodV(Thread*, Method const*, Object*, bool, JValue*, std::__va_list)+292)
#9 pc 00062d2b /system/lib/libdvm.so (dvmCallMethod(Thread*, Method const*, Object*, JValue*, ...)+20)
#10 pc 00057aa3 /system/lib/libdvm.so
#11 pc 0000cde0 /system/lib/libc.so (__thread_entry+72)
#12 pc 0000cf5c /system/lib/libc.so (pthread_create+208)
at android.os.MessageQueue.nativePollOnce(Native Method)
at android.os.MessageQueue.next(MessageQueue.java:132)
at android.os.Looper.loop(Looper.java:124)
at android.os.HandlerThread.run(HandlerThread.java:61)
"Thread-1351" prio=5 tid=21 WAIT
| group="main" sCount=1 dsCount=0 obj=0x430f9a40 self=0x7435c660
| sysTid=11842 nice=10 sched=0/0 cgrp=apps/bg_non_interactive handle=1949682352
| state=S schedstat=( 142708 55157 3 ) utm=0 stm=0 core=2
at java.lang.Object.wait(Native Method)
"Thread-1350" prio=5 tid=20 WAIT
| group="main" sCount=1 dsCount=0 obj=0x430f93f0 self=0x7435c008
| sysTid=11841 nice=10 sched=0/0 cgrp=apps/bg_non_interactive handle=1897340088
| state=S schedstat=( 131927 91823 3 ) utm=0 stm=0 core=2
at java.lang.Object.wait(Native Method)
"Thread-1349" prio=5 tid=19 WAIT
| group="main" sCount=1 dsCount=0 obj=0x430f70e0 self=0x71171330
| sysTid=11840 nice=10 sched=0/0 cgrp=apps/bg_non_interactive handle=1897338752
| state=S schedstat=( 126407 66405 4 ) utm=0 stm=0 core=2
at java.lang.Object.wait(Native Method)
"Thread-1348" prio=5 tid=18 WAIT
| group="main" sCount=1 dsCount=0 obj=0x430f6408 self=0x711709e8
| sysTid=11839 nice=10 sched=0/0 cgrp=apps/bg_non_interactive handle=1897336376
| state=S schedstat=( 197863 87031 5 ) utm=0 stm=0 core=2
at java.lang.Object.wait(Native Method)
"Thread-1347" prio=5 tid=17 WAIT
| group="main" sCount=1 dsCount=0 obj=0x430f55f8 self=0x7116ee98
| sysTid=11838 nice=10 sched=0/0 cgrp=apps/bg_non_interactive handle=1897329384
| state=S schedstat=( 191093 1416250 5 ) utm=0 stm=0 core=2
at java.lang.Object.wait(Native Method)
"Thread-1346" prio=5 tid=16 WAIT
| group="main" sCount=1 dsCount=0 obj=0x430f4468 self=0x71170300
| sysTid=11837 nice=10 sched=0/0 cgrp=apps/bg_non_interactive handle=1897327176
| state=S schedstat=( 109322 34948 2 ) utm=0 stm=0 core=2
at java.lang.Object.wait(Native Method)
"Thread-1345" prio=5 tid=15 WAIT
| group="main" sCount=1 dsCount=0 obj=0x430f3b50 self=0x7116fba0
| sysTid=11836 nice=10 sched=0/0 cgrp=apps/bg_non_interactive handle=1897332920
| state=S schedstat=( 139896 2628645 7 ) utm=0 stm=0 core=0
at java.lang.Object.wait(Native Method)
"Thread-1344" prio=5 tid=14 WAIT
| group="main" sCount=1 dsCount=0 obj=0x430f3a28 self=0x7116cb90
| sysTid=11835 nice=10 sched=0/0 cgrp=apps/bg_non_interactive handle=1897326072
| state=S schedstat=( 205522 129167 2 ) utm=0 stm=0 core=2
at java.lang.Object.wait(Native Method)
"Thread-1343" prio=5 tid=13 WAIT
| group="main" sCount=1 dsCount=0 obj=0x430f3900 self=0x7116bba8
| sysTid=11834 nice=10 sched=0/0 cgrp=apps/bg_non_interactive handle=1897318208
| state=S schedstat=( 7708858 9135572 18 ) utm=0 stm=0 core=0
at java.lang.Object.wait(Native Method)
"[email protected]@430b1b78" daemon prio=5 tid=12 WAIT
| group="main" sCount=1 dsCount=0 obj=0x430b4a10 self=0x71169010
| sysTid=11831 nice=0 sched=0/0 cgrp=apps handle=1897305184
| state=S schedstat=( 91927 0 2 ) utm=0 stm=0 core=0
at java.lang.Object.wait(Native Method)
"AsyncTask #1" prio=5 tid=11 WAIT
| group="main" sCount=1 dsCount=0 obj=0x430acc80 self=0x710d4bd8
| sysTid=11830 nice=10 sched=0/0 cgrp=apps/bg_non_interactive handle=1896697896
| state=S schedstat=( 530989 524949 6 ) utm=0 stm=0 core=3
at java.lang.Object.wait(Native Method)
Hello i have few questions about below code , i think about it very much but i can't to understand it, please help me:
`public class AppController extends Application {
public static final String TAG = AppController.class
.getSimpleName();
private static RequestQueue mRequestQueue;
private static AppController mInstance;
public RequestQueue getRequestQueue() {
if (mRequestQueue == null) {
mRequestQueue = Volley.newRequestQueue(getApplicationContext());
}
return mRequestQueue;
}
@Override
public void onCreate() {
super.onCreate();
mInstance = this;
}
public static synchronized AppController getInstance() {
return mInstance;
}
public <T> void addToRequestQueue(Request<T> req, String tag) {
// set the default tag if tag is empty
req.setTag(TextUtils.isEmpty(tag) ? TAG : tag);
getRequestQueue().add(req);
}
public void addToRequestQueue(Request req) {
getRequestQueue().add(req);
}
public void cancelPendingRequests(Object tag) {
if (mRequestQueue != null) {
mRequestQueue.cancelAll(tag);
}
}
`
why i initialize mInstance = this in oncreate method?
Does/Will Volley support the protocol HTTP/2
Do you know when these recent updates will be included in a build published to jCenter/bintray?
Currently is the only way to get the "NegativeArraySizeException" update is to pull down the entire project and include/build locally?
I would rather use the gradle file for including the dependency.
dependencies {
...
compile 'com.android.volley:volley:1.0.0'
}
Includes the following components:
Because of the mWaitingRequests field of RequestQueue, several Request which have same url and different body, the others request can only be executed after the first Request return. I think this is a little unreasonable, can mWaitingRequests only work for GET method? Common HTTP caches are typically limited to caching responses to GET.
I need to clear error listener after request is cancel (when call onStop()).
Currently that is no way to clear mErrorListener in Request class, which will cause leaked if the error listener implementation is reference fragment or activity.
com.android.volley.RequestQueueIntegrationTest > add_requestProcessedInCorrectOrder FAILED
org.mockito.exceptions.verification.WantedButNotInvoked at RequestQueueIntegrationTest.java:96
Android Studio reported a leaked Activity
that I tracked down to CacheDispatcher
keeping a reference to a request:
The issue was fixed in now deprecated mcxiaoke/android-volley
repository:
leaking the last request object in CacheDispatcher
And the reson for the leak is explained in:
A small leak will sink a great ship
This is server side code
<?php
require('connection.php');
require('functions.php');
$inputJSON = file_get_contents('php://input');
$aReuestData = json_decode( $inputJSON, TRUE ); //convert JSON into array
$user_email = $aReuestData['user_email'];
$user_password = $aReuestData['user_password'];
$user_uniq = $aReuestData['user_uniq_id'];
if((($user_password !='') && ($user_email !=''))|| ($user_uniq!=''))
{
$uname = $user_email;
$pword = $user_password;
$format ='json';
if(($user_password !='') && ($user_email !='')){
echo $checkUser = checkLogin($uname,$pword);
}
else{
$checkUser = checkLoginFacebook($user_uniq);
}
//print_r($checkUser);
if($checkUser['id'] > 0)
{
$result = $checkUser;
}else{
$result = "false";
}
}else{
$result = "Enter username and password";
}
$records = array("result"=> $result);
echo $_REQUEST['jsoncallback']. json_encode($records);
?>
and my code for login activity is
final JSONObject jsonObject = new JSONObject();
try {
jsonObject.put("user_email",username.getText().toString().trim());
jsonObject.put("user_password",password.getText().toString().trim());
} catch (JSONException e) {
e.printStackTrace();
}
requestQueue.start();
final String url = "http://demo4u.org/leaveapp/ws/login.php";
send.setText(jsonObject.toString());
button.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
JsonObjectRequest jsonObjectRequest = new JsonObjectRequest(Request.Method.POST, url, jsonObject,
new Response.Listener<JSONObject>() {
@Override
public void onResponse(JSONObject response) {
Toast.makeText(Login.this,"Passed",Toast.LENGTH_LONG).show();
hello.setText(response.toString());
}
}, new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError error) {
Toast.makeText(Login.this,"Error",Toast.LENGTH_LONG).show();
}
}
);
requestQueue.add(jsonObjectRequest);
}
});
and the only thing that I get returned is
$result = "Enter username and password";
what am I doing wrong? am I to include JSON header or something ???
Please reply in detailed view cause I'm new to android.....
SHOWCASE your skills please....
Hi,
I have a JWT token that I get from a login response. For authentication, I need to set that token for every request later on until that token gets deleted on logout.
How can I read that token, without providing it on JSON body and store it for every future request?
I am quite new with Android development and until now I had really good experience with volley. Now I am struggling at this use case. Any help would be appreciated!
Have a nice day!
I'm having no luck to perform POST request with an array as param, while Postman and OkHttp are doing it correctly: http://stackoverflow.com/questions/43270880/what-is-a-correct-way-to-send-an-array-in-post-request-using-volley
Is it possible at all to encode arrays for POST requests in Volley?
But by default, Volley doesn't know how to deal with gzip response.
Something is wrong here... may be me ;-)
Using the RequestFuture I realized that I can not handle network errors because doing future.get() forces me to implement ExecutionException, InterruptedException and TimeoutException.
By controlling the RequestFuture of the source code, I realized that the onRespoceError method as VolleyError parameter that would be perfect to know the type of network failure by VolleyError.NetworkResponse.
Instead, what is done is a throw new ExecutionException(mException) and then I can not have the VolleyError.NetworkResponse.
RequestFuture<String> future = RequestFuture.newFuture();
StringRequest testRequest = new StringRequest(this.mRequestMethod , url, future, future);
queue.add(testRequest);
try {
String response = future.get(10, TimeUnit.SECONDS); // Blocks for at most 10 seconds.
if(future.isDone()){
callback.onSucces(response);
}
} catch (InterruptedException e) {
// Exception handling
} catch (ExecutionException e) {
callback.onFail(9999 ,e.getMessage());
} catch (TimeoutException e) {
e.printStackTrace();
}
I'm doing something wrong, or it was an oversight during the development of the future?
Thank you
Currently VolelyError and subclasses has @SuppressWarnings("serial") because NetworkResponse is not serializable. Indeed, it is very easy to make it serialziable, as shown in this clone project: mcxiaoke/android-volley@4012176
This will help developer to pass around VolleyError cross process or through Intent (Extras support Serializable).
See discussion at #64
If a null ErrorListener is passed to a Request, Volley just silently doesn't deliver errors. (It previously would crash for a null Listener, which is up to the Request subclass, but that crash is fixed per that pull request). I can't think of a valid scenario where you'd want to pass in a null listener, so we should clean this up everywhere and consider failing more loudly if a null listener or error listener is provided, at least in the classes Volley provides.
如题,并且我通过compile 'com.android.volley:volley:1.0.0' 可以使用,但是找到下载的jar包 拿出来放在项目中还是提示无法找到,请问有人对这个有了解么
This is input side on server in JSON form
{"user_email":"[email protected]","user_password":"123456"}
The returned JSON file is
Array{"result":{"id":"1","name":"ankur","email":"[email protected]","address":"b-block","designation":"devloper","department":"development","balanceleave":"5"}}
my code is
final JSONObject jsonObject = new JSONObject();
try {
jsonObject.put("user_email",login);
jsonObject.put("user_password",passw);
} catch (JSONException e) {
e.printStackTrace();
}
..............
bs.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
JsonObjectRequest jsonObjectRequest = new JsonObjectRequest(Request.Method.PUT,url, jsonObject, new Response.Listener<JSONObject>() {
@Override
public void onResponse(JSONObject response) {
Toast.makeText(Profile.this,"Passes from toast",Toast.LENGTH_LONG).show();
pDialog.dismiss();
}
}, new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError error) {
Toast.makeText(Profile.this,"Error from Toast",Toast.LENGTH_LONG).show();
error.printStackTrace();
}
});
MySingleton.getInstance(Profile.this).addtorequestqueue(jsonObjectRequest);
}
});
Whenever I send the request the error listener gets the response , why the response listener doesn't get the response??
At least I don't see the following commit included in the bintray version:
And we are now encountering the NegativeArraySizeException
bug.
I will compile the library myself anyway. But could you please update that repo?
3xx response is treated as an error - it makes this library useless in many cases.
does the branch 'apache-http' intent to remove apache dependency?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.