我在网上文件后做了一个非常标准的解析注册。除此之外,我尝试在用户注册后通过在SignUpCallback的done(ParseUser user, ParseException e)
方法中调用logInInBackground来实现自动登录。
user.signUpInBackground(new SignUpCallback() {
public void done(ParseException e) {
if (e == null) {
// Hooray! Now sign in with the account that has just been created
ParseUser.logInInBackground(uname, pw, new LogInCallback() {
public void done(ParseUser user, ParseException e) {
if (user != null) {
Log.d("DONE SIGNUP", "STRANGE");
// Hooray! The user is logged in.
// Associate this user with this device
ParseInstallation curIns = ParseInstallation.getCurrentInstallation();
curIns.put("username", user.getUsername());
curIns.saveInBackground();
alertMsg.setText("Signed In");
//Go to the usermainpage activity
Intent mainP = new Intent(ACTLoginSelf.this, ACTRequest.class);
startActivity(mainP);
} else {
// Signup failed. Look at the ParseException to see what happened. =======TBD=========
alertMsg.setText("Missing information, cannot proceed! " + e.getMessage());
}
}
});
} else {
// Sign up didn't succeed. Look at the ParseException
// to figure out what went wrong
//report is there are duplicate accounts existing and such! ============TBD============
}
}
});
我不确定为什么signUpInBackground似乎永远不会“完成”,并且新条目从未填充到Parse用户数据库中。是因为我试图实现自动登录吗?我确保通过在地方添加Log.d
来启动登录,
12-22 14:39:09.210 1570-1570/com.android.inputmethod.latin I/LatinIME: Starting input. Cursor position = 0,0
12-22 14:39:19.033 26189-26189/com.parse.starter D/SIGNING UP: PLEASE WAIT
但它似乎没有完成。
谢谢!
答案 0 :(得分:0)
不要打扰登录。注册时,默认情况下,用户通过注册的Android客户端登录。
您可以按如下方式访问登录用户:
ParseUser user = ParseUser.getCurrentUser();
注册后无需登录。
编辑:事实上,用户会在他们清除缓存或卸载应用程序之前保留他们的登录信息。 (当然,如果您使用Parse SDK以编程方式注销)