예제 #1
0
 /**
  * 通过用户userId获取用户信息<br>
  * 访问网络获取用户信息
  *
  * @param context 上下文
  * @param userid 用户UserId
  */
 public static String getUserInfoByUserId(Context context, String userid) {
   String result = "";
   JSONObject requestObject = new JSONObject();
   try {
     requestObject.put(KEY_USER_ID, userid);
     final RequestResult requestResult = new RequestResult();
     HttpUtil.postSmartRequest(requestObject, Constants.GET_USER_SYNOPSIS, requestResult, context);
     int sc = requestResult.getCode();
     if (sc == HttpStatus.SC_OK) {
       result = requestResult.getResult();
     } else {
       result = String.valueOf(sc);
     }
   } catch (JSONException e) {
     log("getUserInfoByUserId---------JSONException:" + e.toString());
   }
   return result;
 }
예제 #2
0
 /**
  * [新增老人机]<br>
  * 新增老人机
  *
  * @param context 上下文
  * @param deviceId 老人机设备ID
  * @param phoneNumber 老人机监护号码
  * @param nickname 老人昵称
  * @return 返回结果
  */
 public static String doAddOld(
     Context context, String action, String deviceId, String phoneNumber, String nickname) {
   String result = "";
   JSONObject requestObject = new JSONObject();
   try {
     requestObject.put(KEY_OLD_DEVICEID, deviceId);
     requestObject.put(KEY_OLD_PHONE, phoneNumber);
     requestObject.put(KEY_USER_ALIAS, nickname);
     log("--doAddOld--" + requestObject);
     final RequestResult requestResult = new RequestResult();
     HttpUtil.postSmartRequest(requestObject, action, requestResult, context);
     int sc = requestResult.getCode();
     if (sc == HttpStatus.SC_OK) {
       result = requestResult.getResult();
       log("doAddOld---------result:" + result);
     } else {
       result = String.valueOf(sc);
       log("doAddOld---------code:" + sc);
     }
   } catch (JSONException e) {
     log("doAddOld---------JSONException:" + e.toString());
   }
   return result;
 }