我知道如何获得启动当前活动的意图,但是我应该如何构建我的代码,以便如果用户从登录页面进入,会发生一件事,如果他们来自注册页面,则会发生另一件事?
class Login extends Activity {
public final static String EXTRA_MESSAGE = "net.asdqwe.activities.Login.EXTRA_MESSAGE";
//code here
public void onClick(View arg0) {
Intent sendLoggedInUserToHomePage = new Intent(getApplicationContext(), Home.class);
sendLoggedInUserToHomePage.putExtra(EXTRA_MESSAGE,userEmailLoginPage);
startActivity(sendLoggedInUserToHomePage);
}
}
}
asd
class Signup extends Activity {
public final static String EXTRA_MESSAGE = "net.asdqwe.activities.Signup.EXTRA_MESSAGE";
//code here
public void onClick(View arg0) {
Intent signupSuccessHome = new Intent(getApplicationContext(), Home.class);
signupSuccessHome.putExtra(EXTRA_MESSAGE, userEmail);
startActivity(signupSuccessHome);
}
}
现在我们在家里上课,我不知道该怎么办。到目前为止,我只有注册页面,所以很简单:
Intent loggedInUser = getIntent();
userEmailId = loggedInUser.getStringExtra(Signup.EXTRA_MESSAGE);
userInfo = dbTools.getUserInfo(userEmailId);
但是既然我也有来自登录的用户,我该如何更改此代码?