Use the LogPhoneUtil tool class to save APP running logs on Android phones, and android log tool class
Recently, the company's tests have always proposed such a bug. Of course, they also blame their code for poor writing. Therefore, the test will always crash the app, and there is no log printing when they crash, when I come back to reproduce it, sometimes it's really hard to reproduce it, so it's troublesome. To facilitate viewing the cause of the bug in the mobile phone test, I wrote a small tool at home on weekends. I only needed to add the printing of the LogPhoneUtil class when printing the project's Log class, you can easily save logs on the app's mobile phone. A brief introduction is provided. You can view the source code on GIthub. Https://github.com/MuBob/PhoneLogUtil;
First, write the log file management class FileUtil to check whether sdcard exists and create log files under different directories.
Then, create an IOUtil class for reading and writing log files, which is used to operate file streams to write files.
Finally, create the LogUtil class and call the corresponding filter words of the class in the printing area.
When reading and writing files in the LogUtil class, you need to enable the Sub-thread to avoid interface freezing because it is not operated in the main thread, to enable the sub-thread, You need to lock the log file so that you can easily use this tool class.