gpt4 book ai didi

android - 如何使用 parse.com android 获取当前用户信息

转载 作者:行者123 更新时间:2023-11-29 15:57:44 25 4
gpt4 key购买 nike

我正在为 parse.com 开发安卓系统。我已成功登录并使用我的凭据注册,数据也正在上传到我的 parse.com 表中。登录代码段如下:

loginbutton.setOnClickListener(new OnClickListener() {

public void onClick(View arg0) {
// Retrieve the text entered from the EditText
usernametxt = username.getText().toString();
passwordtxt = password.getText().toString();

// Send data to Parse.com for verification
ParseUser.logInInBackground(usernametxt, passwordtxt,
new LogInCallback() {
public void done(ParseUser user, ParseException e) {
if (user != null) {
// If user exist and authenticated, send user to Welcome.class
Intent intent = new Intent(
LoginSignupActivity.this,
Welcome.class);
startActivity(intent);
Toast.makeText(getApplicationContext(),
"Successfully Logged in",
Toast.LENGTH_LONG).show();
finish();
} else {
Toast.makeText(
getApplicationContext(),
"No such user exist, please signup",
Toast.LENGTH_LONG).show();
}
}
});
}
});

现在我需要获取当前用户的信息,请告诉我获取当前用户信息的方法或更改。

提前致谢!

最佳答案

调用 user.getObjectId();user.getString("username"); 是从 ParseObject 获取信息的方式。

loginbutton.setOnClickListener(new OnClickListener() {

public void onClick(View arg0) {
// Retrieve the text entered from the EditText
usernametxt = username.getText().toString();
passwordtxt = password.getText().toString();

// Send data to Parse.com for verification
ParseUser.logInInBackground(usernametxt, passwordtxt,
new LogInCallback() {
public void done(ParseUser user, ParseException e) {
if (user != null) {
// If user exist and authenticated, send user to Welcome.class

String username = user.getString("username");
String userId = user.getObjectId();

Intent intent = new Intent(
LoginSignupActivity.this,
Welcome.class);
startActivity(intent);
Toast.makeText(getApplicationContext(),
"Successfully Logged in",
Toast.LENGTH_LONG).show();
finish();
} else {
Toast.makeText(
getApplicationContext(),
"No such user exist, please signup",
Toast.LENGTH_LONG).show();
}
}
});
}
});

关于android - 如何使用 parse.com android 获取当前用户信息,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26904693/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com