Consider the following scenario:
The class TemplateActivity
extends Activity
. Within onResume()
it performs a validation of a boolean variable then, if false, it finishes the method and the activity, and starts a new activity, OtherActivity
.
When the class ChildActivity
, which extends TemplateActivity
, runs, it waits for super.onResume()
to finish and then continue no matter if its super needs to start the Intent
or not.
The question:
Is there a way to terminate the ChildActivity
when the OtherActivity
needs to start from the TemplateActivity
? Without implementing the validity check in the child class.
Superclass:
class TemplateActivity extends Activity {
@Override
protected void onResume() {
super.onResume();
if(!initialized)
{
startActivity(new Intent(this, OtherActivity.class));
finish();
return;
}
//Do stuff
}
}
Subclass:
class ChildActivity extends TemplateActivity {
@Override
protected void onResume() {
super.onResume();
//Do stuff
}
}