When other programs are open in Android, how do I know when my program loses focus or gains focus?
I’ve seen the View onFocusChanged event, but I think that’s unrelated (when i use a view changer).
How can this be done?
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.
In your
Activity, you can override the life cycle methods. Specifically, onCreate, onStart, onResume, onPause, onStop and onDestroy. The most useful ones are:onCreate: great for one time initialization.onResume: refresh your data because your app is about to take foreground again.onPause: save your data and stop anything that doesn’t need to be running while your app doesn’t have the foreground.See http://developer.android.com/reference/android/app/Activity.html#ActivityLifecycle for a complete overview of these methods and your activities life cycle.