Skip to content

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:

  1. Resolve: message is resolved against the AndroMate context
  2. Duration: duration is mapped to Toast.LENGTH_SHORT / LENGTH_LONG
  3. Main thread: the toast call is posted to the main thread
  4. Show: the toast is displayed
  5. 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.


Complete JSON example

{
  "ShowToast": [
    {
      "id": "1",
      "title": "Show Toast",
      "message": "Hello from AndroMate",
      "duration": "Short"
    }
  ]
}