1
我想作爲ParseUser登錄。一切正常,但第二次點擊按鈕Log in
後。作爲ParseUser登錄後,第二次點擊登錄按鈕後工作
private void openMainActivity(boolean loggedIn) {
if (loggedIn){
startActivity(new Intent(ParseStarterProjectActivity.this, MainPage.class));
finish();
}else{
initialize();
logInBtn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (logIn(username.getText().toString(),pwd.getText().toString())){
startActivity(new Intent(ParseStarterProjectActivity.this, MainPage.class));
finish();
}else{
Toast.makeText(getApplicationContext(),
"Failed to log in, try again.", Toast.LENGTH_LONG).show();
}
}
});
}
}
登錄方法:
private boolean logIn(String username, String pwd) {
ParseUser.logInInBackground(username, pwd, new LogInCallback() {
public void done(ParseUser user, ParseException e) {
if (user != null) {
loggedIn=true;
} else {
loggedIn=false;
}
}
});
return loggedIn;
}
它是時間的問題嗎?它不立即得到EditText
的值,可能是回調延遲?或者有什麼想法?