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

StackOverflow https://stackoverflow.com/questions/18863888

Question

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 correct solution

OTHER TIPS

There is a way to figure out the Activity life-cycle is properly used or not in your project.

In 4.X android version device you can see "Developer Settings" in Settings. In developer setting you have to enable the "Don't keep activities" which is destroyed all the activities in background as soon as possible.

In this case you app activity should not crashed, If its crashed your activity not follow the Android Activity life-cycle.

For your refernces here is the link : http://developer.android.com/training/basics/activity-lifecycle/index.html

I hope , this may help you little bit. :)

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top