For the Log purpose, I want to know the name of method at runtime.
Ex.
public void methodA(){
Log.e("INSIDE", "//some code here to get the name of methodA");
}
If I will get the name of method at runtime, it will reduce my repetitive task of inserting same log in different methods.
I assume this is Java… If that is the case, this returns the name of the method you are currently in.
Be careful though, don’t put this in a method, because then that will return the name of that method. You could also use this:
This observes the second element of the stack trace, returning the correct method name.
UPDATE:
Though the first does what it takes, this is nicer: doesn’t involve creating a new object at least:
Warning I have to mention that all this however has an adverse impact on performance…