本文整理了Java中com.android.volley.toolbox.JsonObjectRequest.setTag()
方法的一些代码示例,展示了JsonObjectRequest.setTag()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。JsonObjectRequest.setTag()
方法的具体详情如下:
包路径:com.android.volley.toolbox.JsonObjectRequest
类名称:JsonObjectRequest
方法名:setTag
暂无
代码示例来源:origin: InnoFang/Android-Code-Demos
private String volleyPostJsonObjectRequest() {
HashMap<String, String> hashMap = new HashMap<>();
hashMap.put("phone", "13429667914");
hashMap.put("key", Constant.JUHE_API_KEY);
JSONObject object = new JSONObject(hashMap);
JsonObjectRequest request = new JsonObjectRequest(Request.Method.POST, Constant.JUHE_URL_POST, object,
new Response.Listener<JSONObject>() {
@Override
public void onResponse(JSONObject response) {
Toast.makeText(MainActivity.this, response.toString(), Toast.LENGTH_SHORT).show();
}
},
new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError error) {
Toast.makeText(MainActivity.this, error.toString(), Toast.LENGTH_SHORT).show();
}
});
request.setTag(JSON_OBJECT_POST_TAG);
MyApplication.getHttpQueues().add(request);
return request.getTag().toString();
}
代码示例来源:origin: xuningjack/AndroidNet
/**
* get请求jsonobject
*/
private void volleyJsonObjectGet(){
Response.Listener<JSONObject> listener = new Response.Listener<JSONObject>() {
@Override
public void onResponse(JSONObject response) {
Toast.makeText(getApplicationContext(), response.toString(), Toast.LENGTH_LONG).show();
Log.d(TAG, "JSONObject-----------" + response.toString());
}
};
JsonObjectRequest request = new JsonObjectRequest(Method.GET, url, null, listener, errorListener);
request.setTag("jackJsonObjectRequest");
MyApplication.getHttpRequestQueue().add(request);
}
代码示例来源:origin: multidots/android-social-signin-helper
private void request(@NonNull Context context, int method, @NonNull String url, @Nullable JSONObject body, @Nullable ApiListener apiListener) {
LISession session = LISessionManager.getInstance(context.getApplicationContext()).getSession();
if (!session.isValid()) {
if (apiListener != null) {
apiListener.onApiError(new LIApiError(LIApiError.ErrorType.accessTokenIsNotSet, "access toke is not set", null));
}
return;
}
JsonObjectRequest jsonObjectRequest = buildRequest(session.getAccessToken().getValue(), method, url, body, apiListener);
jsonObjectRequest.setTag(context == null ? TAG : context);
QueueManager.getInstance(context).getRequestQueue().add(jsonObjectRequest);
}
代码示例来源:origin: InnoFang/Android-Code-Demos
private String volleyGetJsonObjectRequest() {
JsonObjectRequest request = new JsonObjectRequest(Request.Method.GET, Constant.JUHE_URL_GET, null, // 用post方式时,需更改为带请求参数的Object
new Response.Listener<JSONObject>() {
@Override
public void onResponse(JSONObject response) {
Toast.makeText(MainActivity.this, response.toString(), Toast.LENGTH_SHORT).show();
}
},
new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError error) {
Toast.makeText(MainActivity.this, error.toString(), Toast.LENGTH_SHORT).show();
}
});
request.setTag(JSON_OBJECT_GET_TAG);
MyApplication.getHttpQueues().add(request);
return request.getTag().toString();
}
代码示例来源:origin: brainysoon/cyberCar
/**
* **********************************************************************************************
* 得到用户的 汽车列表
*/
public static void sendCarInfoPost(JSONObject mParams, final canHandCarInfosPostResult mHand) {
JsonObjectRequest jsonObjectRequest = new JsonObjectRequest(Request.Method.POST, CAR_INFO_POST_URL, mParams,
new Response.Listener<JSONObject>() {
@Override
public void onResponse(JSONObject jsonObject) {
mHand.handCarInfosPostResutl(jsonObject);
}
}, new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError volleyError) {
mHand.handCarInfosPostError(volleyError);
}
});
//setTag
jsonObjectRequest.setTag(CAR_INFO_POST_TAG);
//add
MyApplication.getRequestQueue().add(jsonObjectRequest);
}
代码示例来源:origin: brainysoon/cyberCar
/**
* *********************************************************************************************
* 查询订单请求
*/
public static void sendMyOrdersPost(JSONObject mParams, final handMyOrdersPost mHand) {
JsonObjectRequest jsonObjectRequest = new JsonObjectRequest(Request.Method.POST, MY_ORDERS_POST_URL,
mParams, new Response.Listener<JSONObject>() {
@Override
public void onResponse(JSONObject jsonObject) {
mHand.handMyOrdersPostResult(jsonObject);
}
}, new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError volleyError) {
mHand.handMyOrdersPostError(volleyError);
}
});
//setTag
jsonObjectRequest.setTag(MY_ORDERS_POST_TAG);
//add
MyApplication.getRequestQueue().add(jsonObjectRequest);
}
代码示例来源:origin: alirezaafkar/JsonRequester
request.setRetryPolicy(new DefaultRetryPolicy(mBuilder.timeOut
, mBuilder.retry, DefaultRetryPolicy.DEFAULT_BACKOFF_MULT));
request.setTag(mBuilder.tag);
mQueue.add(request);
代码示例来源:origin: xuningjack/AndroidNet
request.setTag("jsonPost");
MyApplication.getHttpRequestQueue().add(request);
代码示例来源:origin: brainysoon/cyberCar
private void pullUpdateInfo() {
//用Volley请求服务器最新的版本信息
JsonObjectRequest jsonObjectRequest = new JsonObjectRequest(AUTO_UPDATE_SERVER_ADDRESS, null, new Response.Listener<JSONObject>() {
@Override
public void onResponse(JSONObject jsonObject) {
paserJsonData(jsonObject);
}
}, new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError volleyError) {
volleyError.printStackTrace();
afterUpdate.toDoAfterUpdate();
}
});
//设置超时时间,以及重复请求次数
jsonObjectRequest.setRetryPolicy(new DefaultRetryPolicy(500, 0, DefaultRetryPolicy.DEFAULT_BACKOFF_MULT));
//设置Tag
jsonObjectRequest.setTag(AUTO_UPDATE_SERVER_ADDRESS);
//添加到请求队列里面
MyApplication.getRequestQueue().add(jsonObjectRequest);
}
内容来源于网络,如有侵权,请联系作者删除!