Android Parse,可以注册和注销,但不能登录
我是应用程序开发新手,我通过参考建立我的登录和注册页面。但区别在于,我将登录和注册页面分为两个不同的活动文件和xml文件。我可以注册,可以注销,但不能登录。我想知道我的编码不够完整,无法让登录函数从我的解析数据库中检索用户信息。但在网上翻了三天之后,我仍然找不到解决办法。我需要你们的帮助。这里附加的代码是我的起始页的登录按钮侦听器 ` 启动页面中的我的按钮1将用户链接到注册页面,用户将在那里注册。这是我的注册页面的注册按钮的侦听器Android Parse,可以注册和注销,但不能登录,android,android-studio,parse-platform,login,Android,Android Studio,Parse Platform,Login,我是应用程序开发新手,我通过参考建立我的登录和注册页面。但区别在于,我将登录和注册页面分为两个不同的活动文件和xml文件。我可以注册,可以注销,但不能登录。我想知道我的编码不够完整,无法让登录函数从我的解析数据库中检索用户信息。但在网上翻了三天之后,我仍然找不到解决办法。我需要你们的帮助。这里附加的代码是我的起始页的登录按钮侦听器 ` 启动页面中的我的按钮1将用户链接到注册页面,用户将在那里注册。这是我的注册页面的注册按钮的侦听器 name_input = (EditText)findViewB
name_input = (EditText)findViewById(R.id.name_input);
email_input = (EditText)findViewById(R.id.email_input);
handphoneNo_input = (EditText)findViewById(R.id.handphoneNo_input);
editText = (EditText)findViewById(R.id.editText);
Button signup_button = (Button) findViewById(R.id.signup);
signup_button.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View a) {
name = name_input.getText().toString();
email = email_input.getText().toString();
handphoneNo = handphoneNo_input.getText().toString();
password = editText.getText().toString();
ParseUser user = new ParseUser();
user.setUsername(name);
user.setEmail(email);
user.put("handphone_num", handphoneNo);
user.setPassword(password);
user.signUpInBackground(new SignUpCallback() {
@Override
public void done(ParseException e) {
if(e == null) {
Toast.makeText(getApplicationContext(), "Successfully sign up.", Toast.LENGTH_LONG).show();
Intent intent = new Intent(
register.this,
MainActivity.class);
startActivity(intent);
}else{
Toast.makeText(getApplicationContext(),"Sign Up error.",Toast.LENGTH_LONG).show();
}
}
});
}
});
在登录解析中,您必须输入用于注册用户的名称和密码,而不是电子邮件id和密码。因此,不要在登录页面中输入emailid,而是输入用户的姓名您要检查输入的电子邮件地址和密码是否与数据库中存储的用户详细信息匹配。对于登录,请使用用户名和密码。KCN,ya,可以给出如何操作的线索吗?提前谢谢。@siancheewsee:如果您输入了您用来注册用户的名称,而不是电子邮件id,我会写下答案below@user3069305,但为什么不能使用电子邮件地址登录?这并不能回答这个问题。若要评论或要求作者澄清,请在其帖子下方留下评论。-@AbhinavSinghMaurya:在解析中,为了登录,您必须输入用户名和密码,而不是电子邮件id和密码,不需要更改代码,只需输入用户名而不是电子邮件id
name_input = (EditText)findViewById(R.id.name_input);
email_input = (EditText)findViewById(R.id.email_input);
handphoneNo_input = (EditText)findViewById(R.id.handphoneNo_input);
editText = (EditText)findViewById(R.id.editText);
Button signup_button = (Button) findViewById(R.id.signup);
signup_button.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View a) {
name = name_input.getText().toString();
email = email_input.getText().toString();
handphoneNo = handphoneNo_input.getText().toString();
password = editText.getText().toString();
ParseUser user = new ParseUser();
user.setUsername(name);
user.setEmail(email);
user.put("handphone_num", handphoneNo);
user.setPassword(password);
user.signUpInBackground(new SignUpCallback() {
@Override
public void done(ParseException e) {
if(e == null) {
Toast.makeText(getApplicationContext(), "Successfully sign up.", Toast.LENGTH_LONG).show();
Intent intent = new Intent(
register.this,
MainActivity.class);
startActivity(intent);
}else{
Toast.makeText(getApplicationContext(),"Sign Up error.",Toast.LENGTH_LONG).show();
}
}
});
}
});