I am building a testing/analysis tool that requires instrumentation of Android framework classes. In that tool, the classes need to be instrumented to find out the caller of a method (i.e., method开发者_开发问答 signature) that is currently being executed, and based on the caller some processing is done. My question is, which method I should use to determine the caller?
I know that one approach is to use java.lang.Throwable and the method getStackTrace. However, it is not efficient. Are there any other (public or hidden) API's (similar to sun.reflect.Reflection.getCallerClass of standard JDK) for Android platform that can be used?
There's Thread.getStackTrace().
精彩评论