官术网_书友最值得收藏!

First case

Run your application. Then just go back and leave it. Kill the app. Open Android Monitor, and from the device drop-down list, choose your device instance (emulator or real device). From the next drop-down list, choose the Journaler application package. Observe the following Logcat output:

You will notice the log messages we put in our source code.

Let's check how many times during our interaction with the application we entered the onCreate() and onDestroy() methods. Position your cursor on the search field and type on create. Observe the change in content--there is only one entry when we expected two: one for the main Application class and one for the main activity. Why did this happen? We will find out later:

What does our output contain? It contains the following:

06-27: This is the date the event occurred.

11:37:59.914: This is the time the event occurred.

6713-6713/?: This is the process and thread identifier with the package. Process and thread identifiers are the same if the application has only one thread.

V/Journaler: This is the log level and tag.

[ ON CREATE ]: This is the log message.

Change the filter to on destroy. The content changes to the following:

06-27 11:38:07.317 6713-6713/com.journaler.complete.dev V/Journaler: [ ON DESTROY ]

In your case, you will have different date, time, and pid/tid values.

From the drop-down list, change your filtering from Verbose to Warn. Keep the value for the filter! You will notice that your Logcat is now empty. It's empty because there is no warning messages with the message text containing on destroy. Remove the filter text and return to Verbose level.

Run your application. Lock your screen and unlock it a few times in a row. Then, close and kill the Journaler application. Observe the following Logcat output:

As you can see, it's noticeably entering lifecycle states for pausing and resuming. Finally, we kill our app and an onDestroy() event is triggered. You can see it in Logcat.

If it's easier for you, you can use Logcat from a terminal. Open the terminal and execute the following command line:

adb logcat
主站蜘蛛池模板: 新宾| 荥阳市| 南投县| 萨迦县| 治多县| 兴海县| 宁强县| 仪陇县| 南安市| 怀仁县| 安康市| 峡江县| 颍上县| 铁岭市| 承德市| 贡嘎县| 晋江市| 禄劝| 烟台市| 天祝| 邳州市| 天门市| 沁水县| 昌乐县| 綦江县| 抚顺市| 惠州市| 中江县| 昭通市| 报价| 金寨县| 九江县| 邵阳市| 淅川县| 潞西市| 昂仁县| 六盘水市| 河间市| 永仁县| 丹棱县| 许昌市|