android 常用命令随手记

 

 

 检测工具 lint (a static code analysis tool) : 

    http://developer.android.com/tools/help/lint.html

   A.检测无用的资源文件  

     F:\adt-bundle-windows-x86_64-20140321\sdk\tools>lint --check "UnusedResources"  f:\工程文件目录   > f:\result.txt [文件输出目录]

 

   警告 :1. import android.R   项目中最好不要包含anroid.R 需要使用的地方直接使用全路径

     2. Avoid object allocations during draw/layout operations (preallocate and reuse instead)

    代码 :      protected void onMeasure(){

                     ........

                    DisplayMetrics dm = new DisplayMetrics();

                  }

   3. Consider making the text value selectable by specifying android:textIsSelectable="true"

     从android sdk 11起google添加了新api,TextIsSelectable控制TextView是否支持拷贝、粘帖功能

  4.This Handler class should be static or leaks might occur   Handler 非静态或会引起内存泄漏

     Issue: Ensures that Handler classes do not hold on to a reference to an outer class   确保Handler 没有保持一个外部类的引用
     Id: HandlerLeak

     Since this Handler is declared as an inner class, it may prevent the outer class from being garbage collected. If the Handler is using a Looper or MessageQueue for a thread other than the      main thread, then there is no issue. If the Handler is using the Looper or MessageQueue of the main thread, you need to fix your Handler declaration, as follows: Declare the Handler as a      static class; In the outer class, instantiate a WeakReference to the outer class and pass this object to your Handler when you instantiate the Handler; Make all references to members of        the outer class using the WeakReference object.

   解决方案  http://blog.csdn.net/jdsjlzx/article/details/8463428

 

posted @ 2015-03-19 13:49  杨牧远  阅读(256)  评论(0编辑  收藏  举报