密钥USER LIST预期为String,但值是[Ljava.lang.Object;。已返回默认值<null>

时间:2019-06-18 10:14:51

标签: android string parsing

我正在尝试从Parse回调中检索数据并将其移动到新活动。不幸的是,它在某些不能接受String的强制转换失败。这是我的功能:

private void login(String user, String pass) {
        ParseUser.logInInBackground(user, pass, new LogInCallback() {
            @Override
            public void done(final ParseUser user, ParseException e) {
                if (user != null) {
                    Toast.makeText(MainActivity.this, "login okay", Toast.LENGTH_SHORT).show();
                    moveToUserListActivity();
                } else {
                    Toast.makeText(MainActivity.this, e.getMessage(), Toast.LENGTH_SHORT).show();
                }
            }
        });
    }

private void moveToUserListActivity() {
        ParseQuery<ParseUser> query = ParseUser.getQuery();
        query.findInBackground(new FindCallback<ParseUser>() {
            @Override
            public void done(List<ParseUser> objects, ParseException e) {
                if (e == null && objects != null) {
                    List<String> usersAsString = new ArrayList<>();
                    for (ParseUser parseUser : objects) {
                        String currentUser = parseUser.getUsername();
                        Log.i("all users", parseUser.getUsername());
                        usersAsString.add(currentUser);
                    }
                    Intent intent = new Intent(MainActivity.this, UserListActivity.class);
                    Log.i("all users", String.valueOf(usersAsString));
                    intent.putExtra(USER_LIST, usersAsString.toArray());
                    startActivity(intent);
                } else {
                    Log.i("users list error", e.getMessage());
                }
            }
        });
    }

如果有人指出我做错了,那就太好了。

0 个答案:

没有答案