@Override
 protected void onActivityResult(int requestCode, int resultCode, Intent data) {
   super.onActivityResult(requestCode, resultCode, data);
   if (resultCode != RESULT_OK) {
     return;
   }
   mOnSetAvatarListener.setAvatar(requestCode, data, imAvatar);
 }
  private void registerAppSever() {
    File file =
        new File(
            OnSetAvatarListener.getAvatarPath(RegisterActivity.this, I.AVATAR_TYPE_USER_PATH),
            avatarName + I.AVATAR_SUFFIX_JPG);

    final OkHttpUtils2<Result> utils = new OkHttpUtils2<Result>();
    utils
        .setRequestUrl(I.REQUEST_REGISTER)
        .addParam(I.User.USER_NAME, username)
        .addParam(I.User.PASSWORD, pwd)
        .addParam(I.User.NICK, nick)
        .targetClass(Result.class)
        .addFile(file)
        .execute(
            new OkHttpUtils2.OnCompleteListener<Result>() {
              @Override
              public void onSuccess(Result result) {
                Log.e(TAG, "register fail..." + result.getRetCode());
                pd.dismiss();
                registerEMServer();
                Toast.makeText(
                        getApplicationContext(),
                        R.string.Registration_failed
                            + Utils.getResourceString(RegisterActivity.this, result.getRetCode()),
                        Toast.LENGTH_LONG)
                    .show();
              }

              @Override
              public void onError(String error) {
                Log.e(TAG, "register error..." + error);
                pd.dismiss();
              }
            });
  }