android - Common tasks in Activities methods - how to organize them? -
i have common actions fired in onpause()
, onresume()
methods. (like registering , unregistering broadcatsreceivers
)
now put them in abstract classes , extend activity classes.
after creating abstract classes common actions end situation when can't extend activity because of java's lack of multiple inheritance.
how deal such things? duplicate code or smarter?
i'm wondering if it's wider problem - not concerning android, java language.
task , task b 2 separate tasks. used in 1 class. can have single abstract class. abstract may not necessary if feel there no functions have overridden in child class.
if reason there may task d, uses task alone, can following:
public abstract class extendedabstractactivitya extends activity { public void taska() {} public void taskb() {} //other abstract classes }
you can call these tasks individually respective classes.
Comments
Post a Comment