Skip to content

Instantly share code, notes, and snippets.

View BetweenTwoBits's full-sized avatar

Brandon Davis BetweenTwoBits

View GitHub Profile
@BetweenTwoBits
BetweenTwoBits / enumReflection.kt
Created November 5, 2019 17:06
Get Enum values using reflection hacks
// This code is for obtaining values from Enums that exist in an SDK and are obfuscated for some reason.
for (errorCode in ErrorCode.values()) {
Log.info("ErrorCodes: ${errorCode.name} ${errorCode.getCode()}")
}
private fun Component.getCode():String {
return javaClass.getDeclaredField("value").let {
it.isAccessible = true