简体   繁体   中英

How to read full logs in an apliction?

I have multiple activities in my app. I want to read all logs in txt file. I have used this link Save logs in file in onCreate() of one activity. I am getting only logs of that activty in which i have written code of read logs. Now I want to read all logs in all activities.

Thanks

You can create one BaseActivity and extend this BaseActivity to all the activities.

Now you can write some important code in BaseActivity which can be helpful in all the Activities. This way you don't need to write similar code in All the activities and it will create Base Structure for your project which can be useful to you in future.

Or

You can write one method in Utils class and call that method from every activities, by this way you need to create method only once, but have to call from every activities when needed.

eg

//Creating method in util class
public class Utils{
    public static void addLog(String params, ...){
    /* Your code goes here... */
    }
}

//calling from activities
Utils.addLog(params...);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM