使用Volley时设置自定义CookieManager?

时间:2014-07-26 05:45:16

标签: android android-volley cookiemanager

我移植到Volley,我意识到它并没有管理cookie。然后,我找到了关于如何执行此操作的答案,目前为止最好的是在类CookieHandler的静态方法setDefault()中设置默认CookieHandler

我根据我的自定义CookieManager在许多问题中建议了一个新的CookieStore,但是当我尝试排队请求时,我得到了这个堆栈跟踪:

07-26 00:27:04.509: E/Volley(11414): [22379] NetworkDispatcher.run: Unhandled exception java.lang.NullPointerException

07-26 00:27:04.509: E/Volley(11414): java.lang.NullPointerException

07-26 00:27:04.509: E/Volley(11414):    at java.net.CookieManager.get(CookieManager.java:112)

07-26 00:27:04.509: E/Volley(11414):    at com.android.okhttp.internal.http.HttpEngine.prepareRawRequestHeaders(HttpEngine.java:540)

07-26 00:27:04.509: E/Volley(11414):    at com.android.okhttp.internal.http.HttpEngine.sendRequest(HttpEngine.java:184)

07-26 00:27:04.509: E/Volley(11414):    at com.android.okhttp.internal.http.HttpURLConnectionImpl.execute(HttpURLConnectionImpl.java:345)

07-26 00:27:04.509: E/Volley(11414):    at com.android.okhttp.internal.http.HttpURLConnectionImpl.getResponse(HttpURLConnectionImpl.java:296)

07-26 00:27:04.509: E/Volley(11414):    at com.android.okhttp.internal.http.HttpURLConnectionImpl.getResponseCode(HttpURLConnectionImpl.java:503)

07-26 00:27:04.509: E/Volley(11414):    at com.android.volley.toolbox.HurlStack.performRequest(HurlStack.java:109)

07-26 00:27:04.509: E/Volley(11414):    at com.android.volley.toolbox.BasicNetwork.performRequest(BasicNetwork.java:93)

07-26 00:27:04.509: E/Volley(11414):    at com.android.volley.NetworkDispatcher.run(NetworkDispatcher.java:110)

我使用Android 4.4.2的Moto G进行调试,并在CookieManager对象(Application)中设置了onCreate()

我想我不会错过任何东西。我真的很感激一些解决这个问题的想法,或者一些解决方法。

当默认CookieManager发生更改时,可能与Android Kitkat无法正常工作的错误有关(Android 4.4 KitKat not receiving cookies

0 个答案:

没有答案