我在后端使用 Parse,并且刚刚创建了一个简单的登录应用程序,我试图在其中添加从登录屏幕转到主屏幕的意图。这是我的代码:
public void loginClicked(View v)
{
// 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(){
@Override
public void done(ParseUser user, ParseException e) {
// TODO Auto-generated method stub
if (user != null) {
// If user exist and authenticated, send user to Welcome.class
Intent intent2 = new Intent(MainActivity.this,Home.class);
startActivity(intent2);
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();
}
}});
}
}
因此,根据代码,我的应用程序应该转到“主页”页面,但它会崩溃并停止。有什么办法解决这个问题吗?