天上人间头牌花魁,郑孝美,海贼王漫画743
如下所示:
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; } }
项目开发中,我们根据debug属性来输出日志。
但是有些时候我们想在给公司的测试机上安装的release版本也输出日志,那么这个时候我们到 androidmanifest.xml 中的application 标签中添加属性强制设置debugable即可,如下:
<application android:debuggable="true" tools:ignore="hardcodeddebugmode" .... .... />
init 方法在客户端的第一个activity的oncreate方法中执行一下即可。
以上这篇android 判断是开发debug模式,还是发布release模式的方法就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持移动技术网。
如对本文有疑问,请在下面进行留言讨论,广大热心网友会与你互动!! 点击进行留言回复
Android studio开发小型对话机器人app(实例代码)
Android通过Java sdk的方式接入OpenCv的方法
Android 通过cmake的方式接入opencv的方法步骤
Android Studio finish()方法的使用与解决app点击“返回”(直接退出)
Android 进度条 ProgressBar的实现代码(隐藏、出现、加载进度)
网友评论