Search code examples
androidtestinganalytics

Disable GoogleAnalytics from Android App when testing or developing


I'm using EasyTracker in my Android App and I need a way to disable Analytics tracking when the app is in "development" or "testing" mode (I have a flag in a constants file to discriminate).

What's the best way to do so?

Thanks!


Solution

  • You can use a class with a static boolean value let's say DEBUG like this :

    public final class BuildMode {
            public final static boolean DEBUG = true;
    }
    

    In code, just use :

    if (BuildMode.DEBUG) ...
    

    This is a solution working on all android SDK versions!