I am using ANTLR on the Java8 grammar to parse some Android code, and I'm searching for method invocations having the signature abortBroadcast()
. However, I need to check if abortBroadcast()
is the method from BroadcastReceiver
class, not some method from another class. Is there any way I can get the Class to which the abortBroadcast()
method belongs?
Use Thread.currentThread().getStackTrace()
to get stack trace - there you can find all function calls in current thread. And for every element call getMethodName()
to find your abortBroadcast()
, the getClassName()
will show you class.