Best Way to Include Debug Code?

后端 未结 7 1209
既然无缘
既然无缘 2020-12-24 01:43

I am programming Android applications, and the best way here may or may not be the same as Java in general.

I simply want to be able to set a debug flag that will on

7条回答
  •  情歌与酒
    2020-12-24 02:06

    That's the way I do it:

    // 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');
    }
    

提交回复
热议问题