【发布时间】:2017-09-20 08:45:52
【问题描述】:
protected void onCreate(Bundle savedInstanceState) {
//if user is already logged in open the profile activity directly
if (SharedPrefManager.getInstance(this).isLoggedIn()) {
finish();
startActivity(new Intent(this, Home.class));
}
buttonSignIn.setOnClickListener(this);
buttonSignUp.setOnClickListener(this);
}
如果用户已经登录,有人可以向我解释为什么在启动 Home.class 之前调用 finish()。我正在尝试浏览一些源代码但无法理解这一点。
【问题讨论】:
-
调用finish()后程序执行不会停止。它只是意味着“完成这个活动,然后开始 Home 活动”。
-
好的,finish 是否会查找 startActivty() 函数?
-
如果我在完成和开始活动之间有一些代码行怎么办?
-
在stackoverflow.com/questions/18111245/…之后找到了我真正需要的东西,谢谢大家