findCallerOf

@Nullable()
public static @Nullable() StackTraceElement findCallerOf(Class<? extends Object> target, int skip)

Returns the stack trace element of the immediate caller of the specified class.

Return

the stack trace element representing the immediate caller of the specified class, or null if no caller was found (due to incorrect target, wrong skip count or use of JNI).

Parameters

target

the target class whose callers we are looking for.

skip

the minimum number of calls known to have occurred between the first call to the target class and the point at which the specified throwable was created. If in doubt, specify zero here to avoid accidentally skipping past the caller. This is particularly important for code which might be used in Android, since you cannot know whether a tool such as Proguard has merged methods or classes and reduced the number of intermediate stack frames.