第一种方法:
String Method = Thread.currentThread().getStackTrace()[2].getMethodName();
第二种方法:
private static final boolean FINAL_CONSTANT_IS_LOCAL = true;
private static final String TAG = FooProvider.class.getSimpleName();
private void String getLogTagWithMethod() {
if (FINAL_CONSTANT_IS_LOCAL) {
Throwable stack = new Throwable().fillInStackTrace();
StackTraceElement[] trace = stack.getStatckTrace();
return trace[0].getClassName() + "." + trace[0].getMethodName() + ":" + trace[0].getLineNumber();
} else {
return TAG;
}
}