Android Tutorials - Herong's Tutorial Examples - v3.05, by Herong Yang
onCreate() and Other Callback Methods
This section describes activity callback methods: onCreate(), onStart(), onResume(), onPause(), onStop(), onDestroyed(), and onRestart().
As mentioned in the previous section, the lifecycle of an activity has 4 states and 3 lifetime periods. If you want to monitor and adding your own code logics to an activity, you can use the following 7 basic callback methods provided by the android.app.Activity class:
The following diagram shows the 4 states, 3 lifetime periods and 7 callback methods are related:
--------------------------- onCreate()
| | (Stopped)
| V
| -------------------- onStart() <-- onRestart() <---
| | | (Paused) ^
| | V |
Entire | ------------- onResume() <---------- |
Lifetime | | | ^ |
| Visible | | | |
| Lifetime | | | |
| | Foreground | (Active) | |
| | Lifetime | | |
| | | | | |
| | | V | |
| | ------------- onPause() | |
| | | (Paused) ---->| |
| | V |
| -------------------- onStop() |
| | (Stopped) ----------->|
| V
--------------------------- onDestroy()
(Destroyed)
See next tutorials to implement callback methods.
Table of Contents
Installing JDK 1.8 on Windows System
Installation of Android SDK R24 and Emulator
Installing Apache Ant 1.9 on Windows System
Developing First Android Application - HelloAndroid
Android Application Package (APK) Files
Android Debug Bridge (adb) Tool
AboutAndroid - Application to Retrieve System Information
►android.app.Activity Class and Activity Lifecycle
Introduction of Activity Lifecycle
►onCreate() and Other Callback Methods
ActivityLog - Application to Create Log File
Viewing Activity Log File with "cat" Command in "adb shell"
Implementing Activity Callback Methods
ActivityLog Test - Activity Terminated by User
ActivityLog Test - Activity Stopped and Restarted
ActivityLog Test - Activity Paused and Resumed
View Objects and Layout Resource Files
Using "adb logcat" Command for Debugging
Build Process and Package File Content
Samsung Galaxy Tab 3 Mini Tablet
USB Debugging Applications on Samsung Tablet
USB Debugging Applications on LG-V905R Tablet