get Method Name for debug - Android App

Android examples for App:Log

Description

get Method Name for debug

Demo Code


//package com.java2s;

public class Main {
    public static String getMethodName() {
        StackTraceElement astacktraceelement[] = Thread.currentThread()
                .getStackTrace();//  w ww . j av a  2  s  .com
        if (astacktraceelement == null || astacktraceelement.length < 4
                || astacktraceelement[1] == null) {
            return null;
        } else {
            return astacktraceelement[3].getMethodName();
        }
    }
}

Related Tutorials