ActivityLog Test - Activity Stopped and Restarted
This section provides a tutorial example on how to test activity lifecycle with the ActivityLog application in case user stops the activity by clicking the home icon and restart it again by clicking its name in the application list.
ActivityLog Test #2 - Run ActivityLog and restart it later.
1. Click on the application icon on the emulator's home screen.
"ActivityLog" is listed in the application list.
2. Click on "ActivityLog" to start the application.
Message "Activity created" is displayed on the screen.
3. Click on the "home" button on the emulator control panel.
The emulator home screen is displayed again.
4. Click on the application icon on the emulator's home screen.
Then click on "ActivityLog" in the application list again.
Message "Activity created" is displayed again.
5. Run "adb shell" to view the log file:
# cat Activity.log
Sun Mar 01 19:15:28 2015: Checkpoint #1 - onCreate() called
Sun Mar 01 19:15:28 2015: Checkpoint #2 - onStart() called
Sun Mar 01 19:15:28 2015: Checkpoint #3 - onResume() called
Sun Mar 01 19:15:35 2015: Checkpoint #4 - onPause() called
Sun Mar 01 19:15:37 2015: Checkpoint #5 - onStop() called
Sun Mar 01 19:15:47 2015: Checkpoint #6a - onRestart() called
Sun Mar 01 19:15:47 2015: Checkpoint #2 - onStart() called
Sun Mar 01 19:15:47 2015: Checkpoint #3 - onResume() called
- Clicking the "home" button on the emulator control panel puts the application in the stopped state.
- When clicking the name of the stopped application in the application list,
Android will restart the application by-passing the onCreate() step.
- The calling sequence of callback methods on a stopped-and-restarted activity is:
onStart(), onStart(), onResume(), onPause(), onStop(), onRestart(), onStart(), and onResume().
Table of Contents
About This Book
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
Android File Systems
Android 4.0.3 File Systems
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
Building Your Own Web Browser
Android Command Line Shell
Samsung Galaxy Tab 3 Mini Tablet
USB Debugging Applications on Samsung Tablet
Android Tablet - LG-V905R
USB Debugging Applications on LG-V905R Tablet
Android Phone - LG-P925g
USB Debugging Applications on LG-P925g Phone
Full Version in PDF/EPUB