public class CarMessageTemplate
- Object
- CarTemplate
- CarMessageTemplate
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.
Constructors
public CarMessageTemplate() | Creates an empty message template. |
public CarMessageTemplate(String message) | Creates a message template with the supplied body text. |
Methods
public CarMessageTemplate setTitle(String title) | Sets the header title. |
public String getMessage() | Returns the body text. |
public CarMessageTemplate setMessage(String message) | Sets the body text shown to (and optionally read aloud to) the driver. |
public Image getIcon() | Returns the leading icon, or null. |
public CarMessageTemplate setIcon(Image icon) | Sets the leading icon (e.g. the sender avatar, an error glyph). |
public CarMessageTemplate addAction(CarAction action) | Adds an action button (e.g. “Reply”, “Mark read”, “Retry”). |
public List<CarAction> getActions() | Returns the action buttons, in order. |
public CarActionStrip getHeaderActions() | Returns the header action strip, or null. |
public CarMessageTemplate setHeaderActions(CarActionStrip headerActions) | Sets the header action strip. |
public boolean isLoading() | Returns true when the template should render a loading spinner instead of content. |
public CarMessageTemplate setLoading(boolean loading) | Marks the template as loading; the head unit renders a spinner. |
Inherited methods
From CarTemplate
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
messageString- the body text
Method details
setTitle
public CarMessageTemplate setTitle(String title)Sets the header title.
Parameters
titleString- 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
messageString- 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
iconImage- 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
actionCarAction- 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
headerActionsCarActionStrip- 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
loadingboolean- true to show a spinner
Returns
this template, for chaining