Viewing Activity Log File with "cat" Command in "adb shell"

This section provides a tutorial example on how to test ActivityLog application, find the log file with the 'adb shell' window, and view the log file content with the 'cat' shell command.

Continue from the previous tutorial, I did the following to test my ActivityLog application:

1. Build and install ActivityLog on my Android emulator using the Apache Ant tool.

2. Run the ActivityLog on the emulator. The "Activity created" message displayed on the screen. So the user interface behaves as I expected.

3. Run "adb shell" in a command window to find the log file, which should be located in the application's private file folder, /data/data/<package-name>/files, based what we learned from the previous chapter:

C:\herong>\local\android-sdk-windows\platform-tools\adb shell
# cd /data/data/com.herongyang.activity/files
cd /data/data/com.herongyang.activity/files
# ls -l
ls -l
-rw-rw---- u0_a61   u0_a61   34 2015-03-01 22:46 Activity.log

4. Verify the log file content with "cat" shell command:

# cat Activity.log
cat Activity.log
Activity created
----------------

This confirms that ActivityLog has created the log file correctly. See a similar "adb shell" screenshot below:

adb shell - Viewing Activity Log File
adb shell - Viewing Activity Log File

Of course, you can delete the log file with "rm Activity.log" shell command, if needed.

See next tutorials on adding other activity callback methods to monitor the activity object lifecycle.

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

 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

 Archived Tutorials

 References

 Full Version in PDF/EPUB