Class 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.
-
Constructor Summary
ConstructorsConstructorDescriptionCreates an empty message template.CarMessageTemplate(String message) Creates a message template with the supplied body text. -
Method Summary
Modifier and TypeMethodDescriptionAdds an action button (e.g. "Reply", "Mark read", "Retry").Returns the action buttons, in order.Returns the header action strip, or null.getIcon()Returns the leading icon, or null.Returns the body text.booleanReturns true when the template should render a loading spinner instead of content.setHeaderActions(CarActionStrip headerActions) Sets the header action strip.Sets the leading icon (e.g. the sender avatar, an error glyph).setLoading(boolean loading) Marks the template as loading; the head unit renders a spinner.setMessage(String message) Sets the body text shown to (and optionally read aloud to) the driver.Sets the header title.Methods inherited from class CarTemplate
getTitle
-
Constructor Details
-
CarMessageTemplate
public CarMessageTemplate()Creates an empty message template. -
CarMessageTemplate
Creates a message template with the supplied body text.
Parameters
message: the body text
-
-
Method Details
-
setTitle
Sets the header title.
Parameters
title: the header title
Returns
this template, for chaining
-
getMessage
Returns the body text. -
setMessage
Sets the body text shown to (and optionally read aloud to) the driver.
Parameters
message: the body text
Returns
this template, for chaining
-
getIcon
Returns the leading icon, or null. -
setIcon
Sets the leading icon (e.g. the sender avatar, an error glyph).
Parameters
icon: the icon image
Returns
this template, for chaining
-
addAction
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
-
getHeaderActions
Returns the header action strip, or null. -
setHeaderActions
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
Marks the template as loading; the head unit renders a spinner.
Parameters
loading: true to show a spinner
Returns
this template, for chaining
-