Ben bir webcoder çağrı yapmak için Voleybolu kullanıyorum Yani ... bu çağrıyı yapıyorum null:Android. Volley. volleyError.networkResponse
POST /api/user/login HTTP/1.1
Content-Type: application/json
User-Agent: Dalvik/1.6.0 (Linux; U; Android 4.2.2; Samsung Galaxy S3 - 4.2.2 - API 17 - 720x1280 Build/JDQ39E)
Host: /*No need to show this here.*/
Connection: Keep-Alive
Accept-Encoding: gzip
Content-Length: 43
{"password":"sg","email":"[email protected]"}
Ve bu tepkisini daha alıyorum (401 hatası dikkat edin) :
HTTP/1.1 401 Unauthorized
Server: nginx/1.6.3
Date: Thu, 06 Aug 2015 17:39:15 GMT
Content-Type: application/json; charset=utf-8
Transfer-Encoding: chunked
Connection: keep-alive
X-Powered-By: PHP/5.5.27
{"error":"User is not activated"}
Benim isteği nesne şöyle görünür:
public class CustomJsonObjectRequest extends JsonRequest<JSONObject> {
private Class responseType = null;
public CustomJsonObjectRequest(int method, String url, JSONObject jsonRequest, Response.Listener<org.json.JSONObject> listener, Response.ErrorListener errorListener) {
super(method, url, (jsonRequest == null) ? null : jsonRequest.toString(), listener, errorListener);
}
@Override
protected Response<JSONObject> parseNetworkResponse(NetworkResponse resp) {
return null; //For the purpose of this question, let's presume it's null. It doesn't even enter here, so no use considering what's in here
}
@Override
protected VolleyError parseNetworkError(VolleyError volleyError) {
/** IF I SET A BREAKPOINT ANYWHERE IN HERE ... volleyError.networkResponse WILL BE NULL !!! WHY ?! You can ignore what's below ... it's not really important*/
JSONObject jsonResp = null;
String message = "Could not connect to the server.";// default response
if (volleyError != null && volleyError.networkResponse != null && volleyError.networkResponse.data != null) {
try {
/* get the object */
jsonResp = new JSONObject(new String(volleyError.networkResponse.data));
message = jsonResp.getString("detail");
} catch (JSONException e) {
e.printStackTrace();
}
UDebug.log("PARSED NETWORK ERROR: [" + new VolleyError(message) + "]");
return new VolleyError(message);
}
return new VolleyError(message);
}
}
dünyada gerektiği gibi parseNetworkError
girer, ama neden volleyError.networkResponse
boş mu? volleyError.networkResponse.data
, {"error":"User is not activated"}
dizesini içermelidir. Bu neden olmuyor? Herhangi bir fikir? Bu Durumda bazı ek kod veya izahat gerekiyorsa, bana bildirin
...
Bu bir izin sorunu gibi görünüyor. 4.2.2 ile cihaz, bu bir sanal cihaz mı değil mi? Eğer gerçek bir cihazsa, manifesto, eğer sanal, "yok" ise, sonra yeniden yaratın. Sanal cihazlarda programların beklendiği gibi davranmadığı sorunlar vardı. [Son olarak, bu sorunun olup olmadığını da kontrol edin] (http://databasefaq.com/index.php/answer/179859/java-android-android-studio-android-volley-volley-deliverresponse-not-being-called – Bonatti
Bu en azından ilgili: https://code.google.com/p/android/issues/detail?id=143649 – kaay