测试或开发时,禁止从Android应用程序GoogleAnalytics [英] Disable GoogleAnalytics from Android App when testing or developing
本文介绍了测试或开发时,禁止从Android应用程序GoogleAnalytics的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在我的Android应用程序使用EasyTracker,我需要一种方法来禁用Analytics(分析)跟踪时,应用程序处于发展或测试模式(我有一个常量一个标志文件来区分)。
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?
谢谢!
推荐答案
您可以使用一类具有静态布尔值假设DEBUG是这样的:
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;
}
在code,只需使用:
In code, just use :
if (BuildMode.DEBUG) ...
这是一个解决方案的工作在所有的Android SDK版本!
This is a solution working on all android SDK versions!
这篇关于测试或开发时,禁止从Android应用程序GoogleAnalytics的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文