Android(安卓)判断是开发debug模式,还是发布release模式
16lz
2021-01-24
[java] view plain copy
- public class LogUtils {
- public static boolean APP_DBG = false; // 是否是debug模式
- public static void init(Context context){
- APP_DBG = isApkDebugable(context);
- }
- /**
- * 但是当我们没在AndroidManifest.xml中设置其debug属性时:
- * 使用Eclipse运行这种方式打包时其debug属性为true,使用Eclipse导出这种方式打包时其debug属性为法false.
- * 在使用ant打包时,其值就取决于ant的打包参数是release还是debug.
- * 因此在AndroidMainifest.xml中最好不设置android:debuggable属性置,而是由打包方式来决定其值.
- *
- * @param context
- * @return
- * @author SHANHY
- * @date 2015-8-7
- */
- public static boolean isApkDebugable(Context context) {
- try {
- ApplicationInfo info= context.getApplicationInfo();
- return (info.flags&ApplicationInfo.FLAG_DEBUGGABLE)!=0;
- } catch (Exception e) {
- }
- return false;
- }
- }
更多相关文章
- android attr 属性 类型
- android 基础demo例子
- Android(安卓)卸载应用的两种方式
- Android(安卓)NDK开发之旅29--C++--list、set、map用法
- Android动态布局
- 【Android】BoradcastReceiver ContentProvider
- getReadableDatabase() 和 getWritableDatabase()
- android中Connection.hangup()和Call.hangup()
- Android中取消系统标题栏的几种方式