Java tutorial
//package com.java2s; import android.support.annotation.Nullable; public class Main { private static String getCallOrginMethodName() { StackTraceElement origin = getCallOriginStackTraceElement(); return origin.getMethodName(); } @Nullable private static StackTraceElement getCallOriginStackTraceElement() { StackTraceElement[] trace = new Exception("").getStackTrace(); StackTraceElement origin = null; final int length = trace.length; for (int i = 0; i < length; i++) { StackTraceElement element = trace[i]; String name = element.getClassName(); if (name.equals("sun.reflect.NativeMethodAccessorImpl")) { origin = trace[i - 1]; break; } } return origin; } }