Finish Subclass Activity From Its Superclass
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 meth
Solution 1:
A more elegant solution would be a slightly different approach to the class design:
- Introduce a method
DoStuff()(replace with sensible name) in theTemplateActivity. Do all the // do stuff bits there. - Call this method from the end of
TemplateActivity OnResume - Override it in the child activity to extend it with the child activity // do stuff bits.
- Do not override
onResumein the ChildActivity.
This way, if the condition fires in TemplateActivity OnResume, none of the parent and child DoStuff will be done. The ChildActivityshouldn't have to know anything about this behavior.
Post a Comment for "Finish Subclass Activity From Its Superclass"