android - Calling methods on activity events -
i writing simple android library. have couple of methods executed when activity events happen - after activity got loaded or when activity gets paused.
one way think of create class extends activity, , write methods there, , have "target" activities extend class. methods called
but if end user extending other activity already, method won't work. there better alternative?
if need provide support api 14 or higher, might able make use of application level activity lifecycle callbacks - see application.activitylifecyclecallbacks
interface details.
to make use of need register instance of interface application
instance, using registeractivitylifecyclecallbacks
method. 1 way have developer using library initialise library passing application
instance it. in sdk maintain, , seems work nicely.
Comments
Post a Comment