A QiChatVariable represents a variable in a QiChat Topic. It allows the exchange of data between java code and QiChat scripts.
For further details, see:
Get a QiChatVariable from a QiChatbot containing the topic where the variable is defined:
val qiChatbot: QiChatbot = ...
val nameVariable: QiChatVariable = qiChatbot.variable("name")
QiChatbot qiChatbot = ...;
QiChatVariable nameVariable = qiChatbot.variable("name");
Read and write a QiChatVariable and set a listener to handle a value change:
val nameVariable: QiChatVariable = ...
nameVariable.value = "Pepper"
val name: String = nameVariable.value
nameVariable.addOnValueChangedListener { currentValue -> Log.i(TAG, "onValueChanged: $currentValue") }
QiChatVariable nameVariable = ...;
nameVariable.setValue("Pepper");
String name = nameVariable.getValue();
nameVariable.addOnValueChangedListener(currentValue -> Log.i(TAG, "onValueChanged: " + currentValue));