here is an example which I used for my battery manager extension App Inventor Extensions: Battery Manager | Pura Vida Apps
one of the helper classes looks like that (here for the Health helper blocks)
package com.puravidaapps.TaifunBattery.helpers;
import java.util.HashMap;
import java.util.Map;
import com.google.appinventor.components.common.OptionList;
/**
* Defines a Health type
*/
public enum Health implements OptionList<String> {
Cold("cold"),
Dead("dead"),
Good("good"),
Overheat("overheat"),
OverVoltage("over voltage"),
Unknown("unknown"),
UnspecifiedFailure("unspedified failure");
private String health;
Health(String h) {
this.health = h;
}
public String toUnderlyingValue() {
return health;
}
private static final Map<String, Health> lookup = new HashMap<>();
static {
for(Health h : Health.values()) {
lookup.put(h.toUnderlyingValue(), h);
}
}
public static Health fromUnderlyingValue(String h) {
return lookup.get(h);
}
}
in the main class I just added
import com.puravidaapps.TaifunBattery.helpers.*;
Taifun