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:
|
|
String methodName = new Object(){}.getClass().getEnclosingMethod().getName(); Log.d(“Executed Method”, methodName); |
Related Posts
The homo sapiens behind these blog posts is “Catzie“
An odd human being who happens to have a variety of ever-changing interests, but these days she is often caught coding (Web and Android App Developer for a total of 14+ years!), optimizing this blog, tweaking a Traveler’s Notebook, refilling a cheap fountain pen, making up silly song/rap lyrics, watching K-pop performances, concocting unusual dessert/drink flavors, making scented candles, drawing, painting water-based mixed media pieces, obsessing about how some things works and what unfamiliar words mean, automating repetitive chores, anime, video games… Ran online dessert shops Cookies PH and Catzie’s Cakery in her past life.