[java]  view plain copy
  1. public class LogUtils {  
  2.   
  3.     public static boolean APP_DBG = false// 是否是debug模式  
  4.       
  5.     public static void init(Context context){  
  6.         APP_DBG = isApkDebugable(context);  
  7.     }  
  8.       
  9.     /** 
  10.      * 但是当我们没在AndroidManifest.xml中设置其debug属性时: 
  11.      * 使用Eclipse运行这种方式打包时其debug属性为true,使用Eclipse导出这种方式打包时其debug属性为法false. 
  12.      * 在使用ant打包时,其值就取决于ant的打包参数是release还是debug. 
  13.      * 因此在AndroidMainifest.xml中最好不设置android:debuggable属性置,而是由打包方式来决定其值. 
  14.      *  
  15.      * @param context 
  16.      * @return 
  17.      * @author SHANHY 
  18.      * @date   2015-8-7 
  19.      */  
  20.     public static boolean isApkDebugable(Context context) {  
  21.         try {  
  22.             ApplicationInfo info= context.getApplicationInfo();  
  23.                 return (info.flags&ApplicationInfo.FLAG_DEBUGGABLE)!=0;  
  24.         } catch (Exception e) {  
  25.               
  26.         }  
  27.         return false;  
  28.     }  
  29.       
  30. }  

更多相关文章

  1. android attr 属性 类型
  2. android 基础demo例子
  3. Android(安卓)卸载应用的两种方式
  4. Android(安卓)NDK开发之旅29--C++--list、set、map用法
  5. Android动态布局
  6. 【Android】BoradcastReceiver ContentProvider
  7. getReadableDatabase() 和 getWritableDatabase()
  8. android中Connection.hangup()和Call.hangup()
  9. Android中取消系统标题栏的几种方式

随机推荐

  1. 基于OAC的员工离职数据分析
  2. 高并发第六弹:线程封闭(ThreadLocal)
  3. 如何从Vimeo下载视频?
  4. 一个小时学会Maven
  5. 即将发布的 ASP.NET Core 2.2 会有哪些新
  6. 网络编程基础第四讲阻塞模型
  7. python使用协程并发
  8. python文件流
  9. 利用Syslog Watcher在windows下部署syslo
  10. FNV哈希算法