您可以在从 LoginActivity 启动 CustomerAddActivity 时在 Intent 中传递登录信息
在 LoginActivity
Intent intent = new Intent(this, CustomerAddActivity.class);
intent.putExtra("login_info", "success");
startActivity(intent);
然后在 CustomerAddActivity() 的 onResume() 中删除该登录信息
@Override
protected void onResume() {
super.onResume();
String login = getIntent().getStringExtra("login_info");
if(login != null){
getIntent().removeExtra("login_info");
} else {
startActivity(new Intent(getApplicationContext(), LoginActivity.class));
}
}
因此,每当您的 CustomerAddActivity 进入前台时,它首先会检查 login_info。如果它找不到它将启动 LoginAvctivity。