How to get the identifier of static int of LicenceChecker

When checking the licensing for an application and the public void applicationError(int errorCode) method returns an int, let's say
public static final int ERROR_INVALID_PACKAGE_NAME = 1;

I want to display a message showing the "ERROR_INVALID_PACKAGE_NAME" part of the int. The String error_Code = Integer.toString(errorCode); will only show "1".

How can I get the string from the int?

1 answer

  • answered 2018-07-11 03:48 Gabe Sechan

    There is no way to generate that, the compiler doesn't keep track of the names of variables. And that's ignoring things like proguard which intentionally mangle them. To do that, you either need to use an enum rather than an int, or you need to write a function String convertErrorCodeToString(int errorCode) that returns the string