首页
学习
活动
专区
工具
TVP
发布
社区首页 >问答首页 >Android:如何记录所有活动方法调用?

Android:如何记录所有活动方法调用?
EN

Stack Overflow用户
提问于 2015-05-01 00:58:27
回答 1查看 3K关注 0票数 18

我希望有一种快速的方法,能够记录活动调用的所有超级方法的所有调用。

我已经试过这个https://github.com/stephanenicolas/loglifecycle

但由于某些原因,它不能与AppCompatActivity一起工作。

我可以让IDE重写所有的方法;但是如何将Log添加到所有方法中呢?手动?一定有办法的..。

EN

回答 1

Stack Overflow用户

发布于 2015-05-13 02:15:03

现在是寻找AspectJ http://code.google.com/p/android-aspectj/的时候了,这是一篇完美的文章http://fernandocejas.com/2014/08/03/aspect-oriented-programming-in-android/

您只需要设置方面执行

代码语言:javascript
复制
aspect Trace{
    pointcut traceMethods() : (execution(* com.xyz.*.*(..)));

    before(): traceMethods(){
        Signature sig = thisJoinPointStaticPart.getSignature();
        String sourceName =  thisJoinPointStaticPart.getSourceLocation().getWithinType().getCanonicalName();
        Log.d("AOPLogging: " + sourceName,  "Some method has called")
   }
}

关于可以在AOP上阅读的表达式

票数 4
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/29973631

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档