- Mastering Android Development with Kotlin
- Milo? Vasi?
- 352字
- 2021-07-02 15:20:56
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
- Advanced Quantitative Finance with C++
- ServiceNow Application Development
- Advanced Machine Learning with Python
- C語言程序設計教程
- 數據庫原理及應用(Access版)第3版
- ASP.NET Core 5.0開發入門與實戰
- 騰訊iOS測試實踐
- Instant 960 Grid System
- HTML5游戲開發案例教程
- Nexus規?;疭crum框架
- Java程序設計
- Learning jQuery(Fourth Edition)
- Python預測分析與機器學習
- 人人都能開發RPA機器人:UiPath從入門到實戰
- 3ds Max 2018從入門到精通