If you want to trace the name of the method that’s being executed, the Java code snippet in this page might help you.
This is especially handy when you are debugging by tracking every method that is executed. You can enclose these lines of codes in a function that you call in every method — that’s easier than typing the name for each method you’re tracking, right? 🙂
The String variable methodName
will contain the name of the method where you place the following lines of code:
1 2 |
String methodName = new Object(){}.getClass().getEnclosingMethod().getName(); Log.d("Executed Method", methodName); |