Книга: Beginning Android
onPause() and onResume()
onPause() and onResume()
The onResume()
method is called just before your activity comes to the foreground, either after being initially launched, being restarted from a stopped state, or after a pop-up dialog (e.g., incoming call) is cleared. This is a great place to refresh the UI based on things that may have occurred since the user was last looking at your activity. For example, if you are polling a service for changes to some information (e.g., new entries for a feed), onResume()
is a fine time to both refresh the current view and, if applicable, kick off a background thread to update the view (e.g., via a Handler
).
Conversely, anything that steals your user away from your activity — mostly, the activation of another activity — will result in your onPause()
being called. Here, you should undo anything you did in onResume()
, such as stopping background threads, releasing any exclusive-access resources you may have acquired (e.g., camera), and the like.
Once onPause()
is called, Android reserves the right to kill off your activity’s process at any point. Hence, you should not be relying upon receiving any further events.
- Life, Death, and Your Activity
- My, Myself, and MyLocationOverlay
- Разработка приложений баз данных InterBase на Borland Delphi
- Open Source Insight and Discussion
- Introduction to Microprocessors and Microcontrollers
- Chapter 6. Traversing of tables and chains
- Chapter 8. Saving and restoring large rule-sets
- Chapter 11. Iptables targets and jumps
- Chapter 5 Installing and Configuring VirtualCenter 2.0
- Chapter 16. Commercial products based on Linux, iptables and netfilter
- Appendix A. Detailed explanations of special commands
- Appendix B. Common problems and questions