我希望有一种快速的方法,能够记录活动调用的所有超级方法的所有调用。
我已经试过这个https://github.com/stephanenicolas/loglifecycle了
但由于某些原因,它不能与AppCompatActivity
一起工作。
我可以让IDE重写所有的方法;但是如何将Log添加到所有方法中呢?手动?一定有办法的..。
发布于 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/
您只需要设置方面执行
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上阅读的表达式
https://stackoverflow.com/questions/29973631
复制相似问题