1.在Android.mk中定义一个ENGload时的flag
Android.mk .... ifeq ($(TARGET_BUILD_VARIANT),eng)//user,userdebug. LOCAL_CFLAGS += -D__ENG_LOAD endif
在code中:
#if defined (__ENG_LOAD)
//do sth.
#endif
2.方法2,动态获取
#include <cutils/properties.h> static bool IsEngLoad(){ static int fistCheck =-1; if(fistCheck !=-1){ return firstCheck; } char propbuf[PROPERTY_VALUE_MAX]; property_get("ro.build.type",propbuf,"user"); if (strcmp(propbuf,"eng" == 0)){//is eng load firstCheck = 1; return true; } firstcheck = 0; return false; }
3."user".equals(Build.TYPE)
"userdebug".equals(Build.TYPE)