List Add
Summary
- Internal name:
ListAdd - Category: Collections
- Purpose: Append a string value to the end of a list variable.
- Task type: Normal
Compatibility
-
Minimum AndroMate version:
1.1.0 -
Maximum AndroMate version:
1.1.0 -
Minimum Android:
Android 13 (API 33) -
Maximum Android tested:
Android 16 (API 36) -
Supported manufacturers:
- ✅ All manufacturers
-
Required permissions:
- None
Detailed description
The List Add task appends a string value to the end of an existing list variable. The list grows by one element on each call.
Both list_variable_input and value_input support $variable interpolation — value_input can be a literal string, a variable reference, or a mixed expression such as "item_$index".
The list variable must have been previously initialized with Init List.
Input parameters
| Parameter | Type | Required | Possible values | Android Compatibility | AndroMate Compatibility | Default |
|---|---|---|---|---|---|---|
list_variable_input |
Variable reference | Yes | Declared variable starting with $, holding a valid list |
Android 13 (API 33) → Android 16 (API 36) | 1.1.0 → 1.1.0 | — |
value_input |
String / Variable | Yes | Literal string or $variable reference |
Android 13 (API 33) → Android 16 (API 36) | 1.1.0 → 1.1.0 | "" |
Output parameters
None. The variable referenced by list_variable_input is updated with the new element appended.
Exceptions
| Code | Exception Name | Description |
|---|---|---|
COLLECTION-TASK-002 |
List Variable Name Invalid | list_variable_input is empty or does not start with $. |
RESOLVE-VAR-005 |
Resolve ArrayList Error | The variable does not contain a valid JSON array string. |
Execution flowchart
flowchart TD
Start([Start ListAdd]) --> ResolveList[🔄 Resolve list_variable_input\nfetch ArrayList from context]
ResolveList --> CheckList{Valid list?}
CheckList -->|No| E1[❌ RESOLVE-VAR-005]
CheckList -->|Yes| ResolveValue[🔄 Resolve value_input\nreplace $refs]
ResolveValue --> Add[list.add value]
Add --> Store[💾 setVariableValue\nvar ← updated list]
Store --> Success([✅ VoidResult])
E1 --> Error([❌ Exception])
style Start fill:#e3f2fd
style Success fill:#c8e6c9
style Error fill:#ffcdd2
style ResolveList fill:#fff9c4
style ResolveValue fill:#fff9c4
style Store fill:#c8e6c9
style E1 fill:#ffcdd2
How it works:
- Resolve list: Fetches and parses the JSON array string from the execution context
- Resolve value: Evaluates
value_input—$variablereferences are replaced with their current values - Append: Calls
list.add(resolvedValue) - Store: Serializes the updated list back as a JSON array string and writes it to the context
- Result: Returns
VoidResult