回答
您可以通过使用下面的代码传递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