0
我正在編寫一個Android
應用程序,它將用戶註冊到Parse
平臺並允許用戶註冊並登錄到該應用程序。我可以註冊用戶沒有任何問題。但是,當我在Parse中檢查我的_User表時,它表示密碼未定義。此外,當我登錄時,它給我展示Android:ParseException:無效的登錄憑證
-com.parse.ParseException:無效的登錄憑據
這裏是註冊用戶
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_sign_up);
//initialize parse with credentials
register = (Button) findViewById(R.id.bSignUpConfirm);
register.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
registerUser();
}
});
ActionBar signUpActionBar = getActionBar();
signUpActionBar.setBackgroundDrawable(new ColorDrawable(Color.RED));
}
public void registerUser(){
getSignUpName = (EditText) findViewById(R.id.eGetSignUpName);
getSignUpUsername = (EditText) findViewById(R.id.eGetSignUpUsername);
getSignUpEmail = (EditText) findViewById(R.id.eGetSignUpEmail);
getSignUpPassword = (EditText) findViewById(R.id.eGetSignUpPassword);
getSignUpConfirmPassword = (EditText) findViewById(R.id.eGetSignUpConfirmPassword);
signUpUsername = getSignUpUsername.getText().toString();
signUpName = getSignUpName.getText().toString();
signUpEmail = getSignUpEmail.getText().toString();
signUpPassword = getSignUpPassword.getText().toString();
signUpConfirmPassword = getSignUpConfirmPassword.getText().toString();
ParseUser newUser = new ParseUser();
newUser.setUsername(signUpUsername);
newUser.setEmail(signUpEmail);
newUser.put("fullName", signUpName);
if(signUpPassword.equals(signUpConfirmPassword)){
newUser.setPassword(signUpPassword);
}else{
Toast.makeText(getApplicationContext(), "Password does not match!", Toast.LENGTH_LONG).show();
}
newUser.signUpInBackground(new SignUpCallback() {
@Override
public void done(com.parse.ParseException e) {
if (e == null){
Intent finishRegistration = new Intent(SignUpActivity.this, MainScreen.class);
startActivity(finishRegistration);
}else{
Toast.makeText(getApplicationContext(), "Connection to the server has failed.\n Please try again later.", Toast.LENGTH_LONG).show();
e.printStackTrace();
}
}
});
}
這裏的代碼進行日誌記錄代碼在用戶中
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_login);
ActionBar loginBar = getActionBar();
loginBar.setTitle("Sign In");
loginBar.setBackgroundDrawable(new ColorDrawable(Color.RED));
//initialize parse credentials
Button logIn = (Button) findViewById(R.id.bSignIn);
logIn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
logIn();
}
});
}
public void logIn(){
getLoginUsername = (EditText) findViewById(R.id.eGetLoginUsername);
getLoginPassword = (EditText) findViewById(R.id.eGetLoginUsername);
loginUsername = getLoginUsername.getText().toString();
loginPassword= getLoginPassword.getText().toString();
ParseUser.logInInBackground(loginUsername, loginPassword, new LogInCallback() {
public void done(ParseUser user, ParseException e) {
if (e == null) {
loginSuccessful();
} else {
Toast.makeText(getApplicationContext(),"Wrong Email/Password Combination", Toast.LENGTH_LONG).show();
e.printStackTrace();
}
}
});
}
public void loginSuccessful(){
Intent backToMainIntent = new Intent(LoginActivity.this, MainScreen.class);
startActivity(backToMainIntent);
}
謝謝!
在下面的行旁邊添加一條日誌語句,看看它是否正確執行。 newUser.setPassword(signUpPassword); – Prem
你會如何記錄? P – user3701380