Show Toast
Summary
- Internal name:
ShowToast - Category: Notifications
- Purpose: Display a short, transient toast message on screen.
- 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) -
Required permissions: None
Detailed description
The Show Toast task displays a short text toast. It uses Toast.makeText (a plain text toast), which is allowed from the background on all supported Android versions.
Because workflows run on a background worker thread, the toast is automatically dispatched to the main thread internally - otherwise Android would throw "Can't toast on a thread that has not called Looper.prepare()".
Input parameters
| Parameter | Type | Required | Possible values / Rules | Android Compatibility | AndroMate Compatibility | Default |
|---|---|---|---|---|---|---|
message |
String | Yes | Toast text (supports interpolation) | Android 13 (API 33) -> Android 16 (API 36) | 1.1.0 -> 1.1.0 | "" |
duration |
Enum / String | No | Short (~2s) or Long (~3.5s) |
Android 13 (API 33) -> Android 16 (API 36) | 1.1.0 -> 1.1.0 | Short |
Output parameters
This task produces no output variable. It returns a VoidResult.
Exceptions
This task does not throw exceptions.
Execution flowchart
flowchart TD
Start([ShowToast]) --> Resolve[Resolve message]
Resolve --> Length[Map duration\nShort / Long]
Length --> Main[Dispatch to main thread]
Main --> Toast[Toast.makeText.show]
Toast --> Success([VoidResult])
style Start fill:#e3f2fd
style Success fill:#c8e6c9
style Length fill:#fff9c4
style Toast fill:#c8e6c9
How it works:
- Resolve:
messageis resolved against the AndroMate context - Duration:
durationis mapped toToast.LENGTH_SHORT/LENGTH_LONG - Main thread: the toast call is posted to the main thread
- Show: the toast is displayed
- Result: returns
VoidResult
Code examples
Example 1 - Short toast
{
"ShowToast": [
{
"id": "1",
"title": "Quick toast",
"message": "Step done",
"duration": "Short"
}
]
}
Example 2 - Long toast with a variable
{
"ShowToast": [
{
"id": "2",
"title": "Result toast",
"message": "Speed = $speed_kmh km/h",
"duration": "Long"
}
]
}
Input parameter details
message - Toast text
The text shown in the toast. Supports $variable and ${SPECIAL_VAR} interpolation.
duration - Display duration
Short-> ~2 seconds (Toast.LENGTH_SHORT)Long-> ~3.5 seconds (Toast.LENGTH_LONG)
Any unrecognized value falls back to Short.
Output parameter details
This task produces no output variable.