Activity starter extra only support String or Array

activity starter extra only support string or array, do not support int or boolean, with minimal modification it can be added

if (value instanceof YailList) {
          Log.i(LOG_TAG, "Adding extra list, key = " + key + " value = " + value);
          intent.putExtra(key, ((YailList) value).toStringArray());
        }
        else {
          String stringValue = castExtra.getString(1);
          Log.i(LOG_TAG, "Adding extra string, key = " + key + " value = " + stringValue);
          intent.putExtra(key, stringValue);
        }

then try this

if (value instanceof YailList) {
    Log.i(LOG_TAG, "Adding extra list, key = " + key + " value = " + value);
    intent.putExtra(key, ((YailList) value).toStringArray());
}
else if (value instanceof Integer) {
    Integer intValue = (Integer) value;
    Log.i(LOG_TAG, "Adding extra int, key = " + key + " value = " + intValue);
    intent.putExtra(key, intValue);
}
else if (value instanceof Boolean) {
    Boolean boolValue = (Boolean) value;
    Log.i(LOG_TAG, "Adding extra boolean, key = " + key + " value = " + boolValue);
    intent.putExtra(key, boolValue);
}
else {
    String stringValue = castExtra.getString(1);
    Log.i(LOG_TAG, "Adding extra string, key = " + key + " value = " + stringValue);
    intent.putExtra(key, stringValue);
}

from the extensions directory App Inventor Extensions | Pura Vida Apps

Activity Starter Extension by pepemont, which additionally is able to pass boolean and long values, updated version by Sergio

Taifun

1 Like