本文整理汇总了Java中com.lidroid.xutils.http.RequestParams.addHeader方法的典型用法代码示例。如果您正苦于以下问题:Java RequestParams.addHeader方法的具体用法?Java RequestParams.addHeader怎么用?Java RequestParams.addHeader使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.lidroid.xutils.http.RequestParams
的用法示例。
在下文中一共展示了RequestParams.addHeader方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: doDonate
import com.lidroid.xutils.http.RequestParams; //导入方法依赖的package包/类
void doDonate(int love_id, String money){
RequestParams params = new RequestParams();
params.addHeader("authorization", loginData.getToken());
params.addBodyParameter("love_id", love_id + "");
params.addBodyParameter("money", money);
HttpUtils httpUtils = new HttpUtils();
httpUtils.configCurrentHttpCacheExpiry(1000);
httpUtils.send(HttpRequest.HttpMethod.POST, ApiStores.donate, params, new RequestCallBack<String>() {
@Override
public void onSuccess(com.lidroid.xutils.http.ResponseInfo<String> responseInfo) {
Toast.makeText(context, "捐赠成功", Toast.LENGTH_SHORT).show();
et_donate.setText("");
getDetails(donation.id);
CenterFragment.instance.getMyInfo();
}
@Override
public void onFailure(HttpException e, String s) {
Toast.makeText(context, "请求失败" + s, Toast.LENGTH_SHORT).show();
Log.e("aaa", e.getMessage());
Log.e("aaa", s);
}
});
}
示例2: getDetails
import com.lidroid.xutils.http.RequestParams; //导入方法依赖的package包/类
void getDetails(int donationId){
RequestParams params = new RequestParams();
params.addHeader("authorization", loginData.getToken());
params.addQueryStringParameter("love_id", donationId + "");
HttpUtils httpUtils = new HttpUtils();
httpUtils.configCurrentHttpCacheExpiry(1000);
httpUtils.send(HttpRequest.HttpMethod.GET, ApiStores.getDonationDetail, params, new RequestCallBack<String>() {
@Override
public void onSuccess(com.lidroid.xutils.http.ResponseInfo<String> responseInfo) {
donation = new Gson().fromJson(responseInfo.result, RequestDonation.class).data;
initViews();
}
@Override
public void onFailure(HttpException e, String s) {
Toast.makeText(context, "请求失败", Toast.LENGTH_SHORT).show();
Log.e("aaa", e.getMessage());
Log.e("aaa", s);
}
});
}
示例3: uploadApply
import com.lidroid.xutils.http.RequestParams; //导入方法依赖的package包/类
public void uploadApply(final String certificate, final String name, final String position, final String introduction, final String investorsProjects){
RequestParams params = new RequestParams();
params.addHeader("authorization", loginData.getToken());
params.addBodyParameter("certificate", certificate);
params.addBodyParameter("name", name);
params.addBodyParameter("position", position);
params.addBodyParameter("introduction", introduction);
params.addBodyParameter("investorsProjects", investorsProjects);
HttpUtils httpUtils = new HttpUtils();
httpUtils.send(HttpMethod.POST, "http://116.62.228.37:8000/mine/investors", params, new RequestCallBack<String>() {
@Override
public void onSuccess(com.lidroid.xutils.http.ResponseInfo<String> responseInfo) {
Toast.makeText(delegate.getActivity(), "已提交申请", Toast.LENGTH_SHORT).show();
delegate.setStatus(3);
}
@Override
public void onFailure(HttpException e, String s) {
ToastUtil.showToast("uploadFiles failed", delegate.getActivity());
Log.e("aaa", e.getMessage());
Log.e("aaa", s);
}
});
}
示例4: addPhotoRequest
import com.lidroid.xutils.http.RequestParams; //导入方法依赖的package包/类
public void addPhotoRequest(final String belongId, final File file, final String photoName, INetWorkListener netWorkListener) {
NetWorkTask netWorkTask = new NetWorkTask() {
@Override
public HttpRequest.HttpMethod getHttpMethod() {
return HttpRequest.HttpMethod.POST;
}
@Override
public String getUrl() {
return NetWorkConfig.getHttpApiPath() + "/photo/upload.do";
}
@Override
public RequestParams getRequestParams() {
RequestParams requestParams = new RequestParams();
requestParams.addHeader("enctype", "multipart/form-data");
requestParams.addBodyParameter("belongId", belongId);
requestParams.addBodyParameter("file", file);
requestParams.addBodyParameter("name", photoName);
return requestParams;
}
};
netWorkTask.setNetWorkListener(netWorkListener);
netWorkTask.sendHttpRequest();
}
示例5: getJokeList
import com.lidroid.xutils.http.RequestParams; //导入方法依赖的package包/类
public static void getJokeList(final boolean isRefresh, final int page){
String url = "http://apis.baidu.com/showapi_open_bus/showapi_joke/joke_text";
RequestParams params= new RequestParams();
params.addHeader("apikey", Const.API_KEY);
params.addQueryStringParameter("page", String.valueOf(page));
HttpUtils http = new HttpUtils(10000);
http.send(HttpMethod.GET, url, params, new RequestCallBack<String>() {
@Override
public void onSuccess(ResponseInfo<String> responseInfo) {
Log.i("笑话", responseInfo.result);
Vector<TextJokeEntity> jokeList = JokeParse.parse(responseInfo.result);
Intent intent = new Intent(Const.ACTION_GET_JOKE);
intent.putExtra(Const.KEY_STATUS, Const.GET_JOKE_SUCCESS);
intent.putExtra("isRefresh", isRefresh);
intent.putExtra("jokeList", jokeList);
BaseApplication.getInstance().sendBroadcast(intent);
}
@Override
public void onFailure(HttpException e, String s) {
Log.i("笑话获取失败", e.getMessage() + "");
}
});
}
示例6: saveAddres
import com.lidroid.xutils.http.RequestParams; //导入方法依赖的package包/类
void saveAddres(){
RequestParams params = new RequestParams();
params.addHeader("authorization", loginData.getToken());
params.addBodyParameter("name", name);
params.addBodyParameter("mobile", phone);
params.addBodyParameter("province", province);
params.addBodyParameter("city", city);
params.addBodyParameter("region", region);
params.addBodyParameter("town", "");
params.addBodyParameter("detail", detail);
String requestUrl = ApiStores.addAddress;
if (ISEDIT) {
requestUrl = ApiStores.editAddress;
params.addBodyParameter("addressId", editAddress.id + "");
}
HttpUtils httpUtils = new HttpUtils();
httpUtils.send(HttpRequest.HttpMethod.POST, requestUrl, params, new RequestCallBack<String>() {
@Override
public void onSuccess(com.lidroid.xutils.http.ResponseInfo<String> responseInfo) {
AddressActivity.instance.getAddress();
ToastUtil.showToast("保存成功", context);
finish();
}
@Override
public void onFailure(HttpException e, String s) {
ToastUtil.showToast("保存地址失败" + s, context);
Log.e("aaa", s);
}
});
}
示例7: getDefaultAddress
import com.lidroid.xutils.http.RequestParams; //导入方法依赖的package包/类
void getDefaultAddress(){
RequestParams params = new RequestParams();
params.addHeader("authorization", loginData.getToken());
HttpUtils httpUtils = new HttpUtils();
httpUtils.configDefaultHttpCacheExpiry(100);
httpUtils.send(HttpRequest.HttpMethod.GET, ApiStores.getDefaultAddress, params, new RequestCallBack<String>() {
@Override
public void onSuccess(com.lidroid.xutils.http.ResponseInfo<String> responseInfo) {
defaultAddress = new Gson().fromJson(responseInfo.result, ResponseAddress.class).data;
if (defaultAddress == null) {
selectedAddr = false;
} else {
if (defaultAddress.name != null) {
selectedAddr = true;
tv_address_ame.setText("收件人:" + defaultAddress.name);
tv_address_phone.setText(defaultAddress.mobile);
tv_address_address.setText(defaultAddress.province + defaultAddress.city + defaultAddress.city + defaultAddress.region + defaultAddress.town + defaultAddress.detail);
} else {
selectedAddr = false;
tv_address_ame.setText("收件人:");
tv_address_phone.setText("");
tv_address_address.setText("");
}
}
}
@Override
public void onFailure(HttpException e, String s) {
ToastUtil.showToast("获取默认地址失败", context);
Log.e("aaa", e.getMessage());
Log.e("aaa", s);
}
});
}
示例8: getStringWtihAccess
import com.lidroid.xutils.http.RequestParams; //导入方法依赖的package包/类
/** 获取已登录用户的JSON数据【需要access_token才能访问的数据】
* @param url
* @param access_token 测试用口令在Config中
* @param call
* @return
*/
public static String getStringWtihAccess(String url,String access_token,RequestCallBack<String> call){
HttpUtils httpUtils = new HttpUtils();
RequestParams params =new RequestParams();
params.addHeader("access-token", access_token);
httpUtils.send(HttpRequest.HttpMethod.GET, url, params, call);
return null;
}
示例9: getOnePull
import com.lidroid.xutils.http.RequestParams; //导入方法依赖的package包/类
private void getOnePull() {
SharedPreferences sharedPref = this.getSharedPreferences("userdata",Context.MODE_PRIVATE);
RequestParams params = new RequestParams();
params.addQueryStringParameter("uid", sharedPref.getInt("uid", -1) + "");
SharedPreferences sharedPref1 = this.getSharedPreferences("appdata",Context.MODE_PRIVATE);
params.addHeader("Cookie","JSESSIONID="+sharedPref1.getString("SessionId", ""));
HttpUtils http = new HttpUtils();
http.send(HttpRequest.HttpMethod.GET,
declare.getHost_url() + "remind/unread",
params,
new RequestCallBack<String>() {
@Override
public void onStart() {
Log.i(TAG ,"Pull==>onStart" ) ;
}
@Override
public void onLoading(long total, long current, boolean isUploading) {
}
@Override
public void onSuccess(ResponseInfo<String> responseInfo) {
readingParse(responseInfo.result);
}
@Override
public void onFailure(HttpException error, String msg) {
Log.i(TAG ,"Pull==>error==>" + msg ) ;
}
});
}
示例10: getpostageFee
import com.lidroid.xutils.http.RequestParams; //导入方法依赖的package包/类
void getpostageFee(){
String goodsIds = "", weights = "";
for (CartGoods goods : cartGoodsList.cartGoodsList) {
goodsIds += goods.goodsId + ",";
if(goods.weight.endsWith("G"))
goods.weight = goods.weight.substring(0, goods.weight.length() - 1);
weights += Integer.parseInt(goods.weight) * goods.num + ",";
}
goodsIds = goodsIds.substring(0, goodsIds.length() - 1);
weights = weights.substring(0, weights.length() - 1);
RequestParams params = new RequestParams();
params.addHeader("authorization", loginData.getToken());
params.addBodyParameter("goodsIds", goodsIds);
params.addBodyParameter("weights", weights);
HttpUtils httpUtils = new HttpUtils();
httpUtils.configDefaultHttpCacheExpiry(100);
httpUtils.send(HttpRequest.HttpMethod.POST, ApiStores.getPostageFee, params, new RequestCallBack<String>() {
@Override
public void onSuccess(com.lidroid.xutils.http.ResponseInfo<String> responseInfo) {
postCost = new Gson().fromJson(responseInfo.result, ResponsePostageFee.class).data.postageFee;
if (postCost != -1) {
if (kind.equals("2")) {
iv_price_post.setImageResource(R.mipmap.icon_text_caishenbi);
tv_price_post.setTextColor(context.getResources().getColor(R.color.colorAppRed));
tv_price_post.setText(postCost + "");
} else {
postCost = postCost * 10;
iv_price_post.setImageResource(R.mipmap.icon_text_jifen);
tv_price_post.setTextColor(context.getResources().getColor(R.color.color_yellow_e9));
tv_price_post.setText(postCost + "");
}
calculateMoney();
}
}
@Override
public void onFailure(HttpException e, String s) {
ToastUtil.showToast("获取邮费失败" + s, context);
Log.e("aaa", s);
}
});
}
示例11: send
import com.lidroid.xutils.http.RequestParams; //导入方法依赖的package包/类
private void send(HttpRequest.HttpMethod arg0,RequestParams params){
SharedPreferences sharedPref = context.getSharedPreferences("appdata",Context.MODE_PRIVATE);
params.addHeader("Cookie","JSESSIONID="+sharedPref.getString("SessionId", ""));
http = new HttpUtils();
http.configCurrentHttpCacheExpiry(1000 * 1);
http.send(arg0,
declare.getHost_url() + uri,
params,
new RequestCallBack<String>() {
@Override
public void onStart() {
Log.i(TAG ,"onStart" ) ;
}
@Override
public void onSuccess(ResponseInfo<String> responseInfo) {
Log.i(TAG, "Http==>"+responseInfo.result);
try {
jsonObject = new JSONObject(responseInfo.result);
if(jsonObject.getString("response").equals("error")){
refresh.refresh(jsonObject.getJSONObject("error").getString("text"), -1);
}else if(jsonObject.getString("response").equals("notlogin")){
Toast.makeText(context, "登录过期,请重新登录", Toast.LENGTH_SHORT).show();
Intent intent = new Intent(context,LogOffACTIVITY.class);
intent.putExtra("action", 1);
context.startActivity(intent);
}else {
callback.getResult(jsonObject);
}
} catch (JSONException e) {
e.printStackTrace();
}
}
@Override
public void onFailure(HttpException error, String msg) {
Log.i(TAG ,"error==>" + msg ) ;
refresh.refresh(msg, -1);
}
});
}