Tuesday, 17 September 2013

How to detect/intercept application life cycle events without using the conventional activity life cycle events

How to detect/intercept application life cycle events without using the
conventional activity life cycle events

I wanted to know are there any legal ways to get information about the
activity/application life cycle events from a back ground service / Thread
. Actually , I have a library project where i want to intercept these
calls so that i handle the scenarios when the app using my library goes in
back ground or comes up in life again .
This problem arises because my library does not provide any activities by
default , it intern returns view objects so that the app devs can use the
same in their activities .
So i have no access to the activity life cycle callbacks .
One Possible ways is this :
I make a listener registered to each of the activity created by the app
devs and listener callbacks are needed to called from the onResume ,
onPause() by the app dev , By this way i can have this callbacks
intercepted by a back ground service and hence i will be able to control
the application behavior in onResume , onPause etc .
I wanted to know is there any other efficient/better way to handle this
use case .
Thanks

No comments:

Post a Comment