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


Java RequestParams.setAsJsonContent方法代码示例

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


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

示例1: buildParams

import org.xutils.http.RequestParams; //导入方法依赖的package包/类
@Override
public void buildParams(RequestParams params) {
    // 添加公共参数
    params.addParameter("common_a", "xxxx");
    params.addParameter("common_b", "xxxx");


    // 将post请求的body参数以json形式提交
    params.setAsJsonContent(true);
    // 或者query参数和body参数都json形式
    /*String json = params.toJSONString();
    params.clearParams();// 清空参数
    if (params.getMethod() == HttpMethod.GET) {
        params.addQueryStringParameter("xxx", json);
    } else {
        params.setBodyContent(json);
    }*/
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:19,代码来源:JsonDemoParamsBuilder.java

示例2: ipition

import org.xutils.http.RequestParams; //导入方法依赖的package包/类
@Event(R.id.iption)
private void ipition(View view) {

    if (MedicationHelper.isNullOrEmpty(reg_hospital_name.getText().toString().trim())) {
        new ToastUtil(getApplicationContext(), R.layout.toast_center, "医院名称").show();
        return;
    }

    if (MedicationHelper.isNullOrEmpty(reg_department_name.getText().toString().trim())) {
        new ToastUtil(getApplicationContext(), R.layout.toast_center, "科室名称").show();
        return;
    }
    if (MedicationHelper.isNullOrEmpty(reg_doctor_name.getText().toString().trim())) {
        new ToastUtil(getApplicationContext(), R.layout.toast_center, "医生名称").show();
        return;
    }
    if (MedicationHelper.isNullOrEmpty(reg_reister_time.getText().toString().trim())) {
        new ToastUtil(getApplicationContext(), R.layout.toast_center, "提醒时间").show();
        return;
    }
    if (MedicationHelper.isNullOrEmpty(reminder.getText().toString().trim())) {
        new ToastUtil(getApplicationContext(), R.layout.toast_center, "被提醒人").show();
        return;
    }
    if (MedicationHelper.isNullOrEmpty(reg_type.getText().toString().trim())) {
        new ToastUtil(getApplicationContext(), R.layout.toast_center, "提醒方式").show();
        return;
    }
    medicationUpload = WeiboDialogUtils.createLoadingDialog(RegisteredReminderActivity.this, "上传用药信息中...");
    medicationUpload.show();
    RequestParams params = new RequestParams(AppConstants.BASE_ACTION + AppConstants.APP_REGISTERREMINDS);
    params.setAsJsonContent(true);
    RegisterReminderRequestBean registerReminderRequestBean = new RegisterReminderRequestBean();
    RegisterReminderRequestBean.AppRegisterremindBean appRegisterremindBean = new RegisterReminderRequestBean.AppRegisterremindBean();
    appRegisterremindBean.setToken("426426426");
    appRegisterremindBean.setHosptial_name(reg_hospital_name.getText().toString());
    appRegisterremindBean.setCharacteristic_name(reg_department_name.getText().toString());
    appRegisterremindBean.setDoctor_name(reg_doctor_name.getText().toString());
    appRegisterremindBean.setGet_time(reg_reister_time.getText().toString());
    appRegisterremindBean.setApp_contact_id(contactID);

    if (reg_type.getText().toString().equals("铃声")) {
        appRegisterremindBean.setAlert_mode("1");
    } else if (reg_type.getText().toString().equals("震动")) {
        appRegisterremindBean.setAlert_mode("2");
    } else if (reg_type.getText().toString().equals("短信")) {
        appRegisterremindBean.setAlert_mode("3");
    } else {
        appRegisterremindBean.setAlert_mode("4");
    }


    registerReminderRequestBean.setApp_registerremind(appRegisterremindBean);

    params.setBodyContent(new Gson().toJson(registerReminderRequestBean));
    //    Log.e("json",getApp_contactJsonParam());
    x.http().post(params, new Callback.CommonCallback<String>() {
        @Override
        public void onSuccess(String result) {
            ToastUtils.showShortToast(result);
            WeiboDialogUtils.closeDialog(medicationUpload);
        }

        @Override
        public void onError(Throwable ex, boolean isOnCallback) {
            ToastUtils.showShortToast(ex.getMessage().toString().trim());
            WeiboDialogUtils.closeDialog(medicationUpload);
        }

        @Override
        public void onCancelled(CancelledException cex) {

        }

        @Override
        public void onFinished() {

        }
    });
}
 
开发者ID:MedicationReminder,项目名称:MedicationReminder,代码行数:81,代码来源:RegisteredReminderActivity.java

示例3: btnSend

import org.xutils.http.RequestParams; //导入方法依赖的package包/类
@Event(R.id.btnSend)
private void btnSend(View view){
   if(MedicationHelper.isNullOrEmpty(relay.getText().toString().trim())) {
       ToastUtils.showShortToast("亲,您还没有输入回复内容");
       return;
   }else {
       RequestParams params=new RequestParams("http://101.69.181.251/api/v1/topics/"+QAid+"/create_reply");
       params.setBodyContent("{\"reply\":{\"content\":\" "+relay.getText().toString().trim()+"\"}}");
       params.setAsJsonContent(true);
       x.http().post(params, new Callback.CommonCallback<String>() {
           @Override
           public void onSuccess(String result) {
               relay.setText("");
               relay.requestFocus();
               replyList.clear();
               InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
               imm.hideSoftInputFromWindow(relay.getWindowToken(), 0) ;
               progress_bar.setVisibility(View.VISIBLE);
               commonAdapter.notifyDataSetChanged();
            new Handler().postDelayed(new Runnable() {
                   @Override
                   public void run() {

                       httpGetMainContet();
                       progress_bar.setVisibility(View.GONE);
                   }
               }, DELAY_TIME);

           }

           @Override
           public void onError(Throwable ex, boolean isOnCallback) {

           }

           @Override
           public void onCancelled(CancelledException cex) {

           }

           @Override
           public void onFinished() {

           }
       });
   }

}
 
开发者ID:MedicationReminder,项目名称:MedicationReminder,代码行数:49,代码来源:CreateQuestionAanswerActivity.java

示例4: ipition

import org.xutils.http.RequestParams; //导入方法依赖的package包/类
@Event(R.id.iption)
private void ipition(View view)
{

    if(MedicationHelper.isNullOrEmpty(medName.getText().toString().trim()))
    {
        new ToastUtil(getApplicationContext(), R.layout.toast_center, "药名").show();
        return;
    }

    if(MedicationHelper.isNullOrEmpty(editText4.getText().toString().trim()))
    {
        new ToastUtil(getApplicationContext(), R.layout.toast_center, "服用次数").show();
        return;
    }
    if(MedicationHelper.isNullOrEmpty(selectTime.getText().toString().trim()))
    {
        new ToastUtil(getApplicationContext(), R.layout.toast_center, "服药起始时间").show();
        return;
    }
    if(MedicationHelper.isNullOrEmpty(editText41.getText().toString().trim()))
    {
        new ToastUtil(getApplicationContext(), R.layout.toast_center, "服药间隔时间").show();
        return;
    }
    if(MedicationHelper.isNullOrEmpty(Reminder.getText().toString().trim()))
    {
        new ToastUtil(getApplicationContext(), R.layout.toast_center, "被提醒人").show();
        return;
    }
    if(MedicationHelper.isNullOrEmpty(reminderMode.getText().toString().trim()))
    {
        new ToastUtil(getApplicationContext(), R.layout.toast_center, "提醒方式").show();
        return;
    }
    medicationUpload = WeiboDialogUtils.createLoadingDialog(MedicationReminderActivity.this, "上传用药信息中...");
    medicationUpload.show();
    RequestParams params=new RequestParams(AppConstants.BASE_ACTION+AppConstants.app_drugreminds);
    params.setAsJsonContent(true);
    params.setBodyContent(getApp_contactJsonParam());
    Log.e("json",getApp_contactJsonParam());
    x.http().post(params, new Callback.CommonCallback<String>() {
        @Override
        public void onSuccess(String result) {
         //   ToastUtils.showShortToast(result);
            Log.e("result",result);
           WeiboDialogUtils.closeDialog(medicationUpload);
            new ToastUtil(getApplicationContext(), R.layout.toast_complete, "添加提醒成功").show();
            finish();
        }

        @Override
        public void onError(Throwable ex, boolean isOnCallback) {
            ToastUtils.showShortToast(ex.getMessage().toString().trim());
            WeiboDialogUtils.closeDialog(medicationUpload);
        }

        @Override
        public void onCancelled(CancelledException cex) {

        }

        @Override
        public void onFinished() {

        }
    });
}
 
开发者ID:MedicationReminder,项目名称:MedicationReminder,代码行数:69,代码来源:MedicationReminderActivity.java

示例5: iption

import org.xutils.http.RequestParams; //导入方法依赖的package包/类
@Event(R.id.iption)
private void iption(View view){
    if(user_type==5)
    {
        new ToastUtil(getApplicationContext(), R.layout.toast_center, "联系人类型").show();
        return;
    }
    if(MedicationHelper.isNullOrEmpty(contactUserName.getText().toString().trim()))
    {   new ToastUtil(getApplicationContext(), R.layout.toast_center, "联系人").show();return;}


    if(MedicationHelper.isNullOrEmpty(inputRelation.getText().toString().trim()))
    {
        new ToastUtil(getApplicationContext(), R.layout.toast_center, "关系").show();return;
    }
    if(MedicationHelper.isNullOrEmpty(phoneNumber.getText().toString().trim())) {
        new ToastUtil(getApplicationContext(), R.layout.toast_center, "电话号码").show();return;

    }

    RequestParams params=new RequestParams(AppConstants.BASE_ACTION+AppConstants.app_contacts);
    params.setAsJsonContent(true);
    params.setBodyContent(getApp_contactJsonParam());

    Log.e("params",params.toString());
    Log.e("params",getApp_contactJsonParam());
  //  Log.e("content",getApp_contactJsonParam());
    x.http().post(params, new Callback.CommonCallback<String>() {
        @Override
        public void onSuccess(String result) {
            WeiboDialogUtils.closeDialog(contactUpload);
            new ToastUtil(getApplicationContext(), R.layout.toast_complete, "已添加").show();
           // ToastUtils.showShortToast(result);
            finish();
        }

        @Override
        public void onError(Throwable ex, boolean isOnCallback) {
             ToastUtils.showShortToast("访问接口失败");
        }

        @Override
        public void onCancelled(CancelledException cex) {

        }

        @Override
        public void onFinished() {

        }
    });
    contactUpload = WeiboDialogUtils.createLoadingDialog(AddContactActivity.this, "保存中...");
    contactUpload.show();
}
 
开发者ID:MedicationReminder,项目名称:MedicationReminder,代码行数:55,代码来源:AddContactActivity.java


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