回答
您可以通過使用下面的代碼傳遞JsonRequest。
JsonObjectRequest req = new JsonObjectRequest(Url, new JSONObject(),
new com.android.volley.Response.Listener<JSONObject>() {
@Override
public void onResponse(JSONObject response) {
try {
Log.v("Response:%n %s", response.toString(0));
JSONObject jsonObject = new JSONObject(response.toString());
String success = jsonObject.getString("success");
// Get your Token Here.
} catch (JSONException e) {
e.printStackTrace();
Toast.makeText(LoginActivity.this, "Server or Connection Error.", Toast.LENGTH_SHORT).show();
builder.dismiss();
}
}
}, new com.android.volley.Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError error) {
VolleyLog.e("Error: ", error.getMessage());
}
});
AppController.getInstance().addToRequestQueue(req);
要通過排球請求需要AppController
類。
public class AppController extends Application {
public static final String TAG = AppController.class.getSimpleName();
private RequestQueue mRequestQueue;
private static AppController mInstance;
@Override
public void onCreate() {
super.onCreate();
mInstance = this;
}
public static synchronized AppController getInstance(){
return mInstance;
}
public RequestQueue getRequestQueue(){
if(mRequestQueue == null){
mRequestQueue = Volley.newRequestQueue(getApplicationContext());
}
return mRequestQueue;
}
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 <T> void addToRequestQueue(Request<T> req) {
req.setTag(TAG);
getRequestQueue().add(req);
}
public void cancelPendingRequests(Object tag) {
if (mRequestQueue != null) {
mRequestQueue.cancelAll(tag);
}
}
}
Im sorry .. but that does not help .. im即使用解析的網絡類傳遞請求 @Override public Map
試着用通常的方法取響應..但它給出了一個未知的響應.. ResponseData:[B @ 41a24780 IM正確地得到的StatusCode而主叫response.statuscode .. 但在調用response.data ,我得到未知的迴應(ResponseData:[B @ 41a24780) –
- 1. 解析凌亂的數據
- 2. 解析JSON數據,這是對http獲取請求的響應
- 3. 解析http請求標頭
- 4. 如何從凌亂請求發送arraylist數據並獲取php
- 5. 如何使用Netty獲取http請求/響應頭的大小?
- 6. Groovy的http請求,解析報頭值
- 7. HTTP頭400錯誤的請求響應
- 8. 解析HTTP請求授權頭與Python
- 9. 解析HTTP請求
- 10. 如何在Beanshell Jmeter上獲得響應消息HTTP請求
- 11. Http服務器如何創建請求頭和響應頭
- 12. 從wget解析http響應標頭
- 13. 如何解析Java中的HTTP請求?
- 14. 如何解析C++中的http請求
- 15. 如何跟蹤碼頭中的HTTP請求和響應時間
- 16. 解析HTTP Web響應中的相關請求
- 17. Python是否有解析HTTP請求和響應的模塊?
- 18. 在Python中解析來自http請求的文本響應
- 19. 如何解析java/solrj中Solr分析請求的響應?
- 20. 瞭解HTTP POST請求/響應過程
- 21. AngularJS ng-route如何解析http請求
- 22. 如何發送HTTP請求並獲取HTTP響應
- 23. 從HTTP請求獲取自定義響應標頭
- 24. 在Pharo中發出HTTP請求並獲取響應頭
- 25. 如何解析C中的HTTP響應?
- 26. 發送HTTP請求並解析JSON響應
- 27. F#異步HTTP請求 - 解析JSON響應
- 28. jmeter捕獲所有請求和響應頭單個http請求觸發
- 29. php http請求獲取.text響應
- 30. PHP HTTP請求獲取JSON響應
https://developer.android.com/training/volley/request.html#request-json – BNK
我想你會在這裏找到http://stackoverflow.com/questions/31230308/way-to解決方案-pass-long-parameter-in-url-request-using-volley希望這會對你有所幫助 – Vij