private void saveToCloud() {
   try {
     JSONArray array = new JSONArray();
     for (WrapGroup group : groups) {
       JSONObject object = new JSONObject();
       object.put("groupid", group.getGroupid());
       object.put("title", group.getGroup().getTitle());
       object.put("imageurl", group.getGroup().getImageurl());
       object.put("url", group.getGroup().getUrl());
       array.put(object);
     }
     AVUser user = AVUser.getCurrentUser();
     user.put("groups", array);
     user.saveInBackground(
         new SaveCallback() {
           @Override
           public void done(AVException e) {
             if (e == null) {
               showSnackBar("云端同步完成");
             }
           }
         });
   } catch (JSONException e) {
     e.printStackTrace();
     KLog.e(e);
   }
 }
 public void saveData(AVUser mAvUser) {
   mAvUser.put("selectSubjectName", selectSubjectName);
   mAvUser.put("selectSubjectId", selectSubjectId);
   mAvUser.saveInBackground(
       new SaveCallback() {
         @Override
         public void done(AVException arg0) {
           // TODO Auto-generated method stub
           if (arg0 == null) {
             ShareTools.getInstance()
                 .saveInitMemory(LoginInitMemory.this, selectSubjectId, selectSubjectName);
             Intent intent = new Intent();
             intent.setClass(LoginInitMemory.this, MainHomeActivity.class);
             Bundle mBundle = new Bundle();
             mBundle.putString("subject_id", selectSubjectId);
             mBundle.putString("subject_name", selectSubjectName);
             intent.putExtras(mBundle);
             startActivity(intent);
             overridePendingTransition(R.anim.slide_in_left, R.anim.slide_out_right);
             LoginInitMemory.this.finish();
           } else {
             Toast.makeText(
                     LoginInitMemory.this, "初始化失败,请重试" + arg0.getMessage(), Toast.LENGTH_SHORT)
                 .show();
           }
         }
       });
 }
  /** 修改email(API上说的开启邮箱验证不知道怎么开???) */
  public void updEmail() {
    String email = setEmail.getText().toString();
    AVUser currentUser = AVUser.getCurrentUser();
    if (TextUtils.isEmpty(email) || currentUser == null || !currentUser.isAuthenticated()) return;
    showLoadingDialog("修改邮箱...");

    currentUser.setEmail(email);
    currentUser.saveInBackground(saveCallback);
  }
 public static void updateUserInfo() {
   AVUser user = AVUser.getCurrentUser();
   if (user != null) {
     AVInstallation installation = AVInstallation.getCurrentInstallation();
     if (installation != null) {
       user.put(User.INSTALLATION, installation);
       user.saveInBackground();
     }
   }
 }
 @Click(R.id.id_btn_follow)
 void follow() {
   AVUser user = AVUser.getCurrentUser();
   AVRelation<AVObject> relation = user.getRelation("follow");
   relation.add(mDream.getAVUser("user"));
   user.saveInBackground(
       new SaveCallback() {
         @Override
         public void done(AVException e) {
           if (e == null) {
             showToast("关注成功");
           }
         }
       });
 }
  /** 更新用户名(login和signUp得到的user是授权的) */
  public void updUsername() {
    AVUser user = AVUser.getCurrentUser();
    String usernmae = setUsername.getText().toString();
    if (TextUtils.isEmpty(usernmae)) return;
    if (user == null) {
      Utils.showToast(this, "当前无登陆用户");
      return;
    }
    if (!user.isAuthenticated()) {
      Utils.showToast(this, "当前登陆用户无授权,请重新登录");
      return;
    }
    showLoadingDialog("正在更改username");
    user.setUsername(usernmae); // 自己的用户信息登陆后可以修改
    user.saveInBackground(
        new SaveCallback() {
          @Override
          public void done(AVException e) {
            if (e == null) {
              textView.setText("保存成功");
            } else {
              textView.setText(e.getMessage());
            }
            AVUser user1 = AVUser.getCurrentUser();
            if (user1 != null) {
              Log.i("Session-token", user1.getUsername() + user1.getSessionToken());
            }
            cancelLoadingDialog();
          }
        });

    // 查询得到的user都是没有授权的
    /*ParseQuery<ParseUser> query = ParseUser.getQuery();
    query.getInBackground("WXIMPuEaUZ", new GetCallback<ParseUser>() {
        @Override
        public void done(ParseUser object, ParseException e) {
            if (object != null) {
                object.setUsername("李某某");
                object.saveInBackground(saveCallback);
            }
        }
    });*/
  }
 /** 手动更改密码,更改后自动重新登陆即可同步session-token */
 public void updPassword() {
   final String password = setPassword.getText().toString();
   final AVUser currentUser = AVUser.getCurrentUser();
   if (TextUtils.isEmpty(password) || currentUser == null || !currentUser.isAuthenticated())
     return;
   showLoadingDialog("正在修改密码...");
   currentUser.setPassword(password); // 修改完密码后session-token会失效(再去修改用户信息时异常),重新登陆(重置了session-token)
   currentUser.saveInBackground(
       new SaveCallback() {
         @Override
         public void done(AVException e) {
           if (e == null) { // 修改成功
             cancelLoadingDialog();
             showLoadingDialog("正在重新登陆");
             AVUser.logInInBackground(
                 currentUser.getUsername(),
                 password,
                 new LogInCallback<User>() {
                   @Override
                   public void done(User newUser, AVException e) {
                     if (e == null) {
                       Utils.showToast(UserActivity.this, "重新登陆成功");
                       textView.setText(
                           "Username:"******"\n"
                               + "DisplayName:"
                               + newUser.getDisplayName()
                               + "\n");
                     } else {
                       textView.setText(e.getMessage());
                     }
                     cancelLoadingDialog();
                   }
                 },
                 User.class);
           } else {
             textView.setText(e.getMessage());
             cancelLoadingDialog();
           }
         }
       });
 }