简体   繁体   English

android - 调试时关闭乱舞

[英]android - turn off flurry while debugging

Is there an efficient way to turn off Flurry while debugging? 有没有一种有效的方法可以在调试时关闭Flurry?

Right now the best way I can think of is setting a DEBUG variable to true in one file, and in all of my activities 现在我能想到的最好的方法是在一个文件和我的所有活动中将DEBUG变量设置为true

    super.onStart();
    if(PublicStuff.DEBUG != true) //if debug = false run this code
        FlurryAgent.onStartSession(this, "2C3QVVZMX8Q5M6KF3458");

do I also need to case out the Flurry logEvent methods? 我是否还需要填写Flurry logEvent方法?

is there a better way? 有没有更好的办法?

thanks 谢谢

Look at the isDebuggerConnected() method in the Debug class. 查看Debug类中的isDebuggerConnected()方法。 That tells you exactly what you need to know. 这告诉你究竟需要知道什么。

This is how I went about achieving this. 这就是我实现这一目标的方式。 I create something like a UserEvents class that contains all analytics loggable events (in this case Flurry). 我创建类似于UserEvents类的东西,其中包含所有分析可记录事件(在本例中为Flurry)。 Before I log an event, I check if the build is not in DEBUG mode. 在我记录事件之前,我检查构建是否处于DEBUG模式。 See code sample below: 请参阅以下代码示例:

public class UserEvents {
    public static final String CLICK_RATINGS = "click_ratings";
    public static final String CLICK_SHARE = "click_share";
    public static final String CLICK_CREDITS = "click_credits";
    public static final String CLICK_PRIVACY = "click_privacy";
    ...

    private static boolean isNotLoggable(){
        return BuildConfig.DEBUG;
    }

    public static void logEvent(String event) {
        if(isNotLoggable()) return;
        logEvent(event);
    }

    ...
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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