In iOS when an Application goes to background or when it becomes active, event handlers in App delegate gets invoked. Is there any similar event handlers for Android’s Multitasking?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Not that I know of. I needed the same type of notification in my app as well to do some goes to background cleanup and comes to foreground restore type operations. What I did was subclass Activity and have that subclass call to a manager I wrote to track if the app was in foreground or background. In that subclassed activity call the manager to notify on activity “visible lifetime” events. I.E. call to say in foreground in the activites onStart and call to say in background in onStop. See this link for details of “visible lifetime” scroll down about 2 pages.
I then used my new subclassed activity as the bases for every activity in my program. So now your manager will be able to know whenever a foreground state change occurs. I then used the observer pattern in the manager to allow other objects to register to be notified of foreground state changes. This effectively mimics what we are used to coming from iOS. There may be better ways to do this but this works just fine.