get Class Name - Android java.lang

Android examples for java.lang:Class

Description

get Class Name

Demo Code

public class Main {

  public static String getClassName() {
    try {/*from   w w w  . ja va 2  s . c o  m*/
      String fullClassName = new Exception().getStackTrace()[1].getClassName();
      return fullClassName.substring(fullClassName.lastIndexOf(".") + 1);
    } catch (Exception ex) {
      return "UnknownClass";
    }
  }

}

Related Tutorials