【问题标题】:Android Parse.com getting the id of a userAndroid Parse.com 获取用户的 id
【发布时间】:2015-11-28 11:34:28
【问题描述】:

我正在一个添加关注/关注系统的 android 应用程序中工作,我正在使用 Parse.com 中的行,我有一个用户个人资料,当我点击关注按钮时,应用程序会发送两个用户id(当前用户和其他用户)连续。我正在使用指向 _user 类的指针。

这是我当前的代码:

Intent i = get intent();
String userId =         i.getStringExtra("userid");

ParseObject follow = new     ParseObject("Follow");
  follow.put("from",ParseUser.getCurrentUser());

follow.put("to", userId);
             follow.saveInBackground(new SaveCallback() {
                 @Override
 public void done(ParseException e) {
                  btn_follow.setImageDrawable(getResources().getDrawable(R.drawable.ic_following));
            }
        });

 The btn_follow change the image.     which means the following has been done.     but my Follow class is empty.

我已将我的关注表从: ...|从|到| 到 : ...|从|到|

这很好,两个用户 id 都保存了,但我需要指针而不是字符串,所以我再次放置 from 和 to 指针并删除了该行

 follow.put("to", userId);

这也很有效,但它只保存了当前用户,而不是我试图关注的用户。 所以我的问题是我想关注的用户的 ID。 他们在指南中说

 "ParseUser otheruser = ..."

(我不知道在 3 点中输入什么来获取另一个用户 ID)

【问题讨论】:

    标签: android pointers parse-platform


    【解决方案1】:

    您需要分配一个 ParseObject(或 ParseUser)来在数据库中创建一个指针。为此,您需要创建没有数据的 ParseUser,就像这样:

    follow.put("to", ParseObject.createWithoutData("_User", userId));
    

    此外,您应该检查回调中的 ParseException e 以了解发生了什么。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2013-09-07
      • 2021-11-25
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多