当前位置: 首页>>代码示例>>Java>>正文


Java JsonObjectRequest.setTag方法代码示例

本文整理汇总了Java中com.android.volley.toolbox.JsonObjectRequest.setTag方法的典型用法代码示例。如果您正苦于以下问题:Java JsonObjectRequest.setTag方法的具体用法?Java JsonObjectRequest.setTag怎么用?Java JsonObjectRequest.setTag使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.android.volley.toolbox.JsonObjectRequest的用法示例。


在下文中一共展示了JsonObjectRequest.setTag方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: volleyPostJsonObjectRequest

import com.android.volley.toolbox.JsonObjectRequest; //导入方法依赖的package包/类
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();
}
 
开发者ID:InnoFang,项目名称:Android-Code-Demos,代码行数:24,代码来源:MainActivity.java

示例2: volleyGetJsonObjectRequest

import com.android.volley.toolbox.JsonObjectRequest; //导入方法依赖的package包/类
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();
}
 
开发者ID:InnoFang,项目名称:Android-Code-Demos,代码行数:19,代码来源:MainActivity.java

示例3: getSecret

import com.android.volley.toolbox.JsonObjectRequest; //导入方法依赖的package包/类
public void getSecret(String path, String username) {
    JSONObject body = getDefaultJsonBody();
    try {
        body.put(BODY_PATH, path);
        body.put(BODY_USERNAME, username);
    } catch (JSONException e) {
        e.printStackTrace();
    }

    JsonObjectRequest request = new JsonObjectRequest(
            Request.Method.POST,
            mStorageHelper.getServerAddress() + SECRET_ENDPOINT,
            body,
            this,  // Response.Listener
            this  // Response.ErrorListener
    ) {
        @Override
        public String getBodyContentType() {
            return "application/json; charset=utf-8";
        }
    };

    request.setTag(mTag);
    mRequestQueue.add(request);
}
 
开发者ID:cpoppema,项目名称:pass-mobile-android,代码行数:26,代码来源:SecretApi.java

示例4: getSecrets

import com.android.volley.toolbox.JsonObjectRequest; //导入方法依赖的package包/类
public void getSecrets() {
    JsonObjectRequest request = new JsonObjectRequest(
            Request.Method.POST,
            mStorageHelper.getServerAddress() + SECRETS_ENDPOINT,
            getDefaultJsonBody(),
            this,  // Response.Listener
            this  // Response.ErrorListener
    ) {
        @Override
        public String getBodyContentType() {
            return "application/json; charset=utf-8";
        }
    };

    request.setTag(mTag);
    mRequestQueue.add(request);
}
 
开发者ID:cpoppema,项目名称:pass-mobile-android,代码行数:18,代码来源:SecretsApi.java

示例5: request

import com.android.volley.toolbox.JsonObjectRequest; //导入方法依赖的package包/类
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);
}
 
开发者ID:neurospeech,项目名称:unofficial-linkedin-sdk-android,代码行数:13,代码来源:APIHelper.java

示例6: RequestJsonObjGet

import com.android.volley.toolbox.JsonObjectRequest; //导入方法依赖的package包/类
public static void RequestJsonObjGet(Context context,String url ,String tag,VolleyIntfcObject intface)
{
    SelfApplication.getHttpQueues().cancelAll(tag);
    objectRequest=new JsonObjectRequest(Request.Method.GET,url, null,intface.iListenerObject(),intface.iErrListener());
    objectRequest.setTag(tag);
    SelfApplication.getHttpQueues().add(objectRequest);
    SelfApplication.getHttpQueues().start();
}
 
开发者ID:kdkler,项目名称:VolleyJarProject,代码行数:9,代码来源:VolleyRequest.java

示例7: RequestJsonObjPost

import com.android.volley.toolbox.JsonObjectRequest; //导入方法依赖的package包/类
public static void RequestJsonObjPost(Context context,String url,String tag,JSONObject jsonRequest,VolleyIntfcObject intface)
    {
        SelfApplication.getHttpQueues().cancelAll(tag);
        objectRequest=new JsonObjectRequest(Request.Method.POST,url, jsonRequest,intface.iListenerObject(),intface.iErrListener()){
//            @Override
//            protected Map<String, String> getParams() throws AuthFailureError {
//                return params;
//            }
            //使用StringRequest的时候需要重新getParams()方法,此时不需要重写
            //已经经过方法的测试,这个点需要注意
        };
        objectRequest.setTag(tag);
        SelfApplication.getHttpQueues().add(objectRequest);
        SelfApplication.getHttpQueues().start();
    }
 
开发者ID:kdkler,项目名称:VolleyJarProject,代码行数:16,代码来源:VolleyRequest.java

示例8: Volley_get

import com.android.volley.toolbox.JsonObjectRequest; //导入方法依赖的package包/类
public static void Volley_get(String url, String ReqMethod, final TextView tvID) {

        JsonObjectRequest req=new JsonObjectRequest(Request.Method.GET, url, null, new Response.Listener<JSONObject>() {
           String res="";
            @Override
            public void onResponse(JSONObject jsonObject) {
                //执行成功的回调
                Log.d("tag", "onResponse: 成功获取");
                try
                {
                    res =jsonObject.getString("TimeLineID");

                    Log.d("TAG", "onResponse: "+jsonObject.getString("TimeLineID"));
                }
                catch (JSONException e)
                {
                    e.printStackTrace();
                }
            }

        },new Response.ErrorListener(){
            @Override
            public void onErrorResponse(VolleyError volleyError) {
                Log.d("tag", "onResponse: 失败获取");
                Log.d("TAG", "onErrorResponse: "+volleyError.getMessage());
                //执行失败的回调
                tvID.setText("获取失败");
            }
        });
        req.setTag("get timelinelist");

        VoleyApp.getHttpQueues().add(req);

    }
 
开发者ID:kdkler,项目名称:VolleyJarProject,代码行数:35,代码来源:CommonHelper.java

示例9: requestGet

import com.android.volley.toolbox.JsonObjectRequest; //导入方法依赖的package包/类
public static void requestGet(String url, String tag, VolleyInterface vif) {
    MyApplication.getRequestQueue().cancelAll(tag);
    mRequest = new JsonObjectRequest(Request.Method.GET,url, null,vif.loadListener(),vif.errorListener());
    mRequest.setTag(tag);
    MyApplication.getRequestQueue().add(mRequest);
    MyApplication.getRequestQueue().start();
}
 
开发者ID:bianwl,项目名称:kanxue,代码行数:8,代码来源:VolleyRequest.java

示例10: requestPost

import com.android.volley.toolbox.JsonObjectRequest; //导入方法依赖的package包/类
public static void requestPost(String url, String tag, final Map<String, String> params, VolleyInterface vif) {
    MyApplication.getRequestQueue().cancelAll(tag);
   mRequest = new JsonObjectRequest(url,null,vif.loadListener(),vif.errorListener()){
       @Override
       protected Map<String, String> getParams() throws AuthFailureError {
           return params;
       }
   };
    mRequest.setTag(tag);
    MyApplication.getRequestQueue().add(mRequest);
    MyApplication.getRequestQueue().start();
}
 
开发者ID:bianwl,项目名称:kanxue,代码行数:13,代码来源:VolleyRequest.java

示例11: onBackgrounds

import com.android.volley.toolbox.JsonObjectRequest; //导入方法依赖的package包/类
@Override
public void onBackgrounds() {
    // 开票通知-通知详情
    final String url = MyAPI.getBaseUrl() + "/api/Funds/InvoiceNotice/GetInvoiceNoticeById?id=" + getArguments().getInt("id");
    final JsonObjectRequest jsonObjectRequest = new JsonObjectRequest(Request.Method.GET, url, new Response.Listener<org.json.JSONObject>() {
        @Override
        public void onResponse(org.json.JSONObject response) {
            LogUtils.d("\n开票通知-通知详情-URL:" + url + "\n开票通知-通知详情-RESPONSE:" + response.toString());

            T_InvoiceNoticeDetailsEntity entity = JSON.parseObject(response.toString(), T_InvoiceNoticeDetailsEntity.class);

            if (entity == null) {
                showView(tv_no_data);
                hideView(mProgressBar);
                return;
            }

            tv_details_ordercode.setText(entity.getOrderCode());
            tv_details_code.setText(entity.getCode());
            tv_details_adviceDate.setText(StringUtil.dateRemoveT(entity.getAdviceDate()));
            tv_details_draweeName.setText(entity.getDraweeName());
            tv_details_titleName.setText(entity.getTitleName());
            tv_details_amount.setText(StringUtil.numberFormat(entity.getAmount()));
            tv_details_address.setText(entity.getAddress());

            Object remark = entity.getRemark();
            if (remark != null)
                tv_details_remark.setText((String) remark);

            tv_titleName.setText(entity.getTitleName());
            tv_address.setText(entity.getAddress());
            tv_phone.setText(entity.getPhone());
            tv_taxCode.setText(entity.getTaxCode());

            Object bank = entity.getBank();
            if (bank != null)
                tv_bank.setText((String) bank);

            Object bankAccount = entity.getBankAccount();
            if (bankAccount != null)
                tv_bankAccount.setText((String) bankAccount);

            showView(mNestedScrollView);
            hideView(mProgressBar);

        }
    }, new Response.ErrorListener() {
        @Override
        public void onErrorResponse(VolleyError error) {
            mProgressBar.setVisibility(View.VISIBLE);
            LogUtils.e("请求错误:" + error.toString());
        }
    }) {
        @Override
        public Map<String, String> getHeaders() throws AuthFailureError {
            Map<String, String> map = new HashMap<>();
            map.put(AppDelegate.QS_LOGIN, MyApplication_.getInstance().getUserInfoSp().getString(AppDelegate.LOGIN_NAME, ""));
            return map;
        }
    };

    jsonObjectRequest.setTag(this);
    mRequestQueue.add(jsonObjectRequest);
}
 
开发者ID:jpaijh,项目名称:TYT,代码行数:65,代码来源:T_InvoiceNoticeDetails_InvoiceDetailsFragment.java

示例12: onBackgrounds

import com.android.volley.toolbox.JsonObjectRequest; //导入方法依赖的package包/类
@Override
public void onBackgrounds() {
    // 获取开票通知-商品列表
    final String url = MyAPI.getBaseUrl() + "/api/Funds/InvoiceNotice/GetInvoiceNoticeById?id=" + getArguments().getInt("id");
    JsonObjectRequest jsonObjectRequest = new JsonObjectRequest(Request.Method.GET, url, new Response.Listener<org.json.JSONObject>() {
        @Override
        public void onResponse(org.json.JSONObject response) {
            LogUtils.d("\n开票通知-商品列表-URL:" + url + "\n开票通知-商品列表-nRESPONSE:" + response.toString());

            JSONObject jsonObject = JSON.parseObject(response.toString());
            JSONArray details = jsonObject.getJSONArray("details");
            List<T_InvoiceNoticeDetailsEntity.DetailsEntity> detailsEntities = JSON.parseArray(details.toString(), T_InvoiceNoticeDetailsEntity.DetailsEntity.class);

            if (detailsEntities.size() == 0) {
                showView(tv_no_data);
            } else {
                hideView(tv_no_data);
            }

            if (detailsEntities != null) {
                mAdapter = new MyInvoiceNoticeProductsAdapter(detailsEntities);
                mRecyclerView.setAdapter(mAdapter);
            }

            if (!isFirstLoading)
                createRefreshCompleteSnackbar(mRecyclerView);

            mSwipeRefreshLayout.setRefreshing(false);
        }
    }, new Response.ErrorListener() {
        @Override
        public void onErrorResponse(VolleyError error) {
            LogUtils.e("请求错误:" + error.toString());
        }
    }) {
        @Override
        public Map<String, String> getHeaders() throws AuthFailureError {
            Map<String, String> map = new HashMap<>();
            map.put(AppDelegate.QS_LOGIN, MyApplication_.getInstance().getUserInfoSp().getString(AppDelegate.LOGIN_NAME, ""));
            return map;
        }
    };

    jsonObjectRequest.setTag(this);
    mRequestQueue.add(jsonObjectRequest);
}
 
开发者ID:jpaijh,项目名称:TYT,代码行数:47,代码来源:T_InvoiceNoticeDetails_ProductsDetailsFragment.java

示例13: onBackgrounds

import com.android.volley.toolbox.JsonObjectRequest; //导入方法依赖的package包/类
@Override
public void onBackgrounds() {
    final String URL = MyAPI.getBaseUrl() + "/api/PlatformAccounts/Account/GetAccount?id=" + userInfoSp.getString(AppDelegate.ACCOUNT_ID, "");
    JsonObjectRequest jsonObjectRequest = new JsonObjectRequest(Request.Method.GET, URL, new Response.Listener<org.json.JSONObject>() {
        @Override
        public void onResponse(org.json.JSONObject response) {
            LogUtils.d("\n专属客服-URL:" + URL + "\n专属客服-RESPONSE:" + response.toString());
            // "clerk": { "clerkId": 2761505,"clerkName": "刘玲","clerkMobile": "11111","clerkTelephone": "","clerkEmail": null, "clerkQq": "" }
            JSONObject jsonObject = JSON.parseObject(response.toString());
            JSONObject clerk = jsonObject.getJSONObject("clerk");
            clerkName = clerk.getString("clerkName");
            clerkMobile = clerk.getString("clerkMobile");
            String clerkTelephone = clerk.getString("clerkTelephone");
            String clerkEmail = clerk.getString("clerkEmail");
            String clerkQq = clerk.getString("clerkQq");

            tv_clerkName.setText(clerkName);
            tv_clerkMobile.setText(clerkMobile);
            tv_clerkTelephone.setText(clerkTelephone);
            tv_clerkEmail.setText(clerkEmail);
            tv_clerkQq.setText(clerkQq);

            // 只要有一项信息不为空就 显示
            if (!TextUtils.isEmpty(clerkName) || !TextUtils.isEmpty(clerkMobile)
                    || !TextUtils.isEmpty(clerkTelephone) || !TextUtils.isEmpty(clerkEmail) || !TextUtils.isEmpty(clerkQq)) {
                showView(mCardView);
            } else {
                tv_no_data.setText("暂无专属客服");
                showView(tv_no_data);
            }

            hideView(mProgressbar);
        }
    }, new Response.ErrorListener() {
        @Override
        public void onErrorResponse(VolleyError error) {
            LogUtils.e("请求错误:" + error.toString());
            mProgressbar.setVisibility(View.GONE);
        }
    }) {
        @Override
        public Map<String, String> getHeaders() throws AuthFailureError {
            Map<String, String> map = new HashMap<>();
            map.put(AppDelegate.QS_LOGIN, userInfoSp.getString(AppDelegate.LOGIN_NAME, ""));
            return map;
        }
    };

    jsonObjectRequest.setTag(this);
    mRequestQueue.add(jsonObjectRequest);
}
 
开发者ID:jpaijh,项目名称:TYT,代码行数:52,代码来源:T_CustomerServiceActivity.java

示例14: onCreateView

import com.android.volley.toolbox.JsonObjectRequest; //导入方法依赖的package包/类
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {

	View view = inflater.inflate(R.layout.fr_json_request, container,false);

	carDataList = new ArrayList<Map<String, String>>();

	lvCar = (ListView) view.findViewById(R.id.lv_car);
	adapter = new SimpleAdapter(getActivity(), carDataList, R.layout.fr_json_request_list_item, keys, ids);
	lvCar.setAdapter(adapter);

	// 发起请求

	JsonObjectRequest request = new JsonObjectRequest(StringUtil.preUrl(Constants.DEFAULT_JSON_REQUEST_URL), null,
			new Listener<JSONObject>() {

				@Override
				public void onResponse(JSONObject response) {
					try {
						if (!response.has("result")) {
							return;
						}

						JSONObject result = response.getJSONObject("result");

						if (!result.has("fctlist")) {
							return;
						}

						JSONArray factoryArray = result.getJSONArray("fctlist");

						if (factoryArray.length() == 0) {
							return;
						}

						JSONObject factory = factoryArray.getJSONObject(0);

						if (!factory.has("serieslist")) {
							return;
						}

						JSONArray seriesArray = factory.getJSONArray("serieslist");

						carDataList.clear();

						for (int i = 0; i < seriesArray.length(); i++) {
							JSONObject series = seriesArray.getJSONObject(i);
							Map<String, String> seriesMap = new HashMap<String, String>();

							seriesMap.put("name", series.getString("name"));
							seriesMap.put("level", "级别:"+series.getString("levelname"));
							seriesMap.put("price", "价格:"+series.getString("price"));

							carDataList.add(seriesMap);

						}
						
						adapter.notifyDataSetChanged();

					} catch (Exception e) {
						ToastUtil.showToast(getActivity(), getResources().getString(R.string.request_fail_text));
					}

				}
			}, new ErrorListener() {

				@Override
				public void onErrorResponse(VolleyError arg0) {
					ToastUtil.showToast(getActivity(), getResources().getString(R.string.request_fail_text));
				}
			});
	// 请求加上Tag,用于取消请求
	request.setTag(this);

	VolleyUtil.getQueue(getActivity()).add(request);

	return view;
}
 
开发者ID:xulailing,项目名称:android-open-project-demo-master,代码行数:79,代码来源:JsonRequestFragment.java


注:本文中的com.android.volley.toolbox.JsonObjectRequest.setTag方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。