private static Boolean isDebug = null; public static boolean isDebug(){ return isDebug == null ? false : isDebug.booleanValue(); } //ctx.getApplicationInfo().flags & ApplicationInfo.FLAG_DEBUGGABLE debug状态下指为2 public static void initIsDebug(Context ctx){ if (isDebug == null){ isDebug = ctx.getApplicationInfo() != null && (ctx.getApplicationInfo().flags & ApplicationInfo.FLAG_DEBUGGABLE) != 0; }
}
在调用isDebug()获取之前在,在application中初始化initIsDebug(Context ctx)。