# Class CarMessageTemplate

java.lang.Object
com.codename1.car.CarTemplate
com.codename1.car.CarMessageTemplate

public class CarMessageTemplate extends CarTemplate

A short message with an icon and action buttons -- an error/empty state, a permission prompt, or (for communication apps) an incoming-message card with read-aloud and voice-reply actions. Maps to `androidx.car.app.model.MessageTemplate` and `CPInformationTemplate` / a CarPlay messaging list item.

Communication apps must additionally hold the platform messaging entitlement (`ios.carplay.messaging` build hint on iOS; the `androidx.car.app.category.MESSAGING` intent filter the builder injects on Android). Without it the message still renders but voice reply is unavailable.

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `CarMessageTemplate()`
  Creates an empty message template.
  `CarMessageTemplate(String message)`
  Creates a message template with the supplied body text.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `CarMessageTemplate`
  `addAction(CarAction action)`
  Adds an action button (e.g. "Reply", "Mark read", "Retry").
  `List<CarAction>`
  `getActions()`
  Returns the action buttons, in order.
  `CarActionStrip`
  `getHeaderActions()`
  Returns the header action strip, or null.
  `Image`
  `getIcon()`
  Returns the leading icon, or null.
  `String`
  `getMessage()`
  Returns the body text.
  `boolean`
  `isLoading()`
  Returns true when the template should render a loading spinner instead of content.
  `CarMessageTemplate`
  `setHeaderActions(CarActionStrip headerActions)`
  Sets the header action strip.
  `CarMessageTemplate`
  `setIcon(Image icon)`
  Sets the leading icon (e.g. the sender avatar, an error glyph).
  `CarMessageTemplate`
  `setLoading(boolean loading)`
  Marks the template as loading; the head unit renders a spinner.
  `CarMessageTemplate`
  `setMessage(String message)`
  Sets the body text shown to (and optionally read aloud to) the driver.
  `CarMessageTemplate`
  `setTitle(String title)`
  Sets the header title.

  ### Methods inherited from class CarTemplate

  `getTitle`

  ### Methods inherited from class Object

  `clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- ## Constructor Details

  - ### CarMessageTemplate

    public CarMessageTemplate()
    Creates an empty message template.

  - ### CarMessageTemplate

    public CarMessageTemplate(String message)

    Creates a message template with the supplied body text.

    ###### Parameters

    - `message`: the body text

- ## Method Details

  - ### setTitle

    public CarMessageTemplate setTitle(String title)

    Sets the header title.

    ###### Parameters

    - `title`: the header title

    ###### Returns

    this template, for chaining

  - ### getMessage

    public String getMessage()
    Returns the body text.

  - ### setMessage

    public CarMessageTemplate setMessage(String message)

    Sets the body text shown to (and optionally read aloud to) the driver.

    ###### Parameters

    - `message`: the body text

    ###### Returns

    this template, for chaining

  - ### getIcon

    public Image getIcon()
    Returns the leading icon, or null.

  - ### setIcon

    public CarMessageTemplate setIcon(Image icon)

    Sets the leading icon (e.g. the sender avatar, an error glyph).

    ###### Parameters

    - `icon`: the icon image

    ###### Returns

    this template, for chaining

  - ### addAction

    public CarMessageTemplate addAction(CarAction action)

    Adds an action button (e.g. "Reply", "Mark read", "Retry"). The head unit shows at most two.

    ###### Parameters

    - `action`: the action button

    ###### Returns

    this template, for chaining

  - ### getActions

    public List<CarAction> getActions()
    Returns the action buttons, in order.

  - ### getHeaderActions

    public CarActionStrip getHeaderActions()
    Returns the header action strip, or null.

  - ### setHeaderActions

    public CarMessageTemplate setHeaderActions(CarActionStrip headerActions)

    Sets the header action strip.

    ###### Parameters

    - `headerActions`: the action strip

    ###### Returns

    this template, for chaining

  - ### isLoading

    public boolean isLoading()
    Returns true when the template should render a loading spinner instead of content.

  - ### setLoading

    public CarMessageTemplate setLoading(boolean loading)

    Marks the template as loading; the head unit renders a spinner.

    ###### Parameters

    - `loading`: true to show a spinner

    ###### Returns

    this template, for chaining