Send variables to Kustom via Broadcast

Kustom from version 2.09 allows third party apps to send variables via broadcasts. In order to send a broadcast to Kustom you will need this static entries defined in your code:

public static final String KUSTOM_ACTION = "org.kustom.action.SEND_VAR";
public static final String KUSTOM_ACTION_EXT_NAME = "org.kustom.action.EXT_NAME";
public static final String KUSTOM_ACTION_VAR_NAME = "org.kustom.action.VAR_NAME";
public static final String KUSTOM_ACTION_VAR_VALUE = "org.kustom.action.VAR_VALUE";
public static final String KUSTOM_ACTION_VAR_NAME_ARRAY = "org.kustom.action.VAR_NAME_ARRAY";
public static final String KUSTOM_ACTION_VAR_VALUE_ARRAY = "org.kustom.action.VAR_VALUE_ARRAY";

Then you will need to send a broadcast always providing an "EXT_NAME" and then providing either a single name/value pair or an array of them. So, for example, if we have an application called "foo" that wants to send "myvar" with value "myvalue" you will do something like this:

Intent intent = new Intent(KUSTOM_ACTION);
intent.putExtra(KUSTOM_ACTION_EXT_NAME, "foo");
intent.putExtra(KUSTOM_ACTION_VAR_NAME, "myvar");
intent.putExtra(KUSTOM_ACTION_VAR_VALUE, "myvalue");

Then in Kustom you will have to use $br(foo, myvar)$ to access the data. Finally, if you want to send more than one variable at a time you can use the VALUE_ARRAY and NAME_ARRAY extras, just ensure the amount of entries is the same on both.

Was this article helpful?
1 out of 1 found this helpful