开发者

In Android, how do I find caller of a method efficiently

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().

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜