我编程Android应用,并在这里的最佳方式可以是或可以不是相同的Java一般
I am programming Android applications, and the best way here may or may not be the same as Java in general.
我只是希望能够设置调试标志,将只执行了code某部分时,它被设置为真 - 当量为C ++设置preprocessor的#define调试和使用的#ifdef DEBUG。
I simply want to be able to set a debug flag that will only execute certain portions of code when it's set to true––equiv to C++ setting a preprocessor #define DEBUG and using #ifdef DEBUG.
有没有一个公认的或最好的方式做到这一点在Java中?
Is there an accepted or best way to accomplish this in Java?
现在我只是要设置在我的应用程序对象的变量,但我不想象这是最好的方式。
Right now I'm just going to set a variable in my Application object, but I don't imagine this is the best way.
这是我做的方式:
// in some.class.with.Constants
public static final boolean DEV_MODE = true;
// in some other class
import static some.class.with.Constants.DEV_MODE;
if(DEV_MODE){
Log.d('sometag', 'somemessage');
}
上一篇:Session对象不更新ASP.NET对象、Session、NET、ASP
下一篇:什么ShadowCopyFiles财产的AppDomain呢?财产、ShadowCopyFiles、AppDomain