Class Card (0.1.0)

public final class Card extends GeneratedMessageV3 implements CardOrBuilder

A card interface displayed in a Google Chat message or Google Workspace Add-on.

Cards support a defined layout, interactive UI elements like buttons, and rich media like images. Use cards to present detailed information, gather information from users, and guide users to take a next step.

Card builder

To learn how to build cards, see the following documentation:

  • For Google Chat apps, see Design dynamic, interactive, and consistent UIs with cards.
  • For Google Workspace Add-ons, see Card-based interfaces.

    Example: Card message for a Google Chat app

    !Example contact card

    To create the sample card message in Google Chat, use the following JSON:

    <code><code> { "cardsV2": [ { "cardId": "unique-card-id", "card": { "header": { "title": "Sasha", "subtitle": "Software Engineer", "imageUrl": "https://developers.google.com/chat/images/quickstart-app-avatar.png", "imageType": "CIRCLE", "imageAltText": "Avatar for Sasha", }, "sections": [ { "header": "Contact Info", "collapsible": true, "uncollapsibleWidgetsCount": 1, "widgets": [ { "decoratedText": { "startIcon": { "knownIcon": "EMAIL", }, "text": "sasha&#64;example.com", } }, { "decoratedText": { "startIcon": { "knownIcon": "PERSON", }, "text": "&lt;font color=&#92;"#80e27e&#92;"&gt;Online&lt;/font&gt;", }, }, { "decoratedText": { "startIcon": { "knownIcon": "PHONE", }, "text": "+1 (555) 555-1234", } }, { "buttonList": { "buttons": [ { "text": "Share", "onClick": { "openLink": { "url": "https://example.com/share", } } }, { "text": "Edit", "onClick": { "action": { "function": "goToView", "parameters": [ { "key": "viewType", "value": "EDIT", } ], } } }, ], } }, ], }, ], }, } ], } </code></code>

Protobuf type google.apps.card.v1.Card

Implements

CardOrBuilder

Static Fields

CARD_ACTIONS_FIELD_NUMBER

public static final int CARD_ACTIONS_FIELD_NUMBER
Field Value
TypeDescription
int

DISPLAY_STYLE_FIELD_NUMBER

public static final int DISPLAY_STYLE_FIELD_NUMBER
Field Value
TypeDescription
int
public static final int FIXED_FOOTER_FIELD_NUMBER
Field Value
TypeDescription
int

HEADER_FIELD_NUMBER

public static final int HEADER_FIELD_NUMBER
Field Value
TypeDescription
int

NAME_FIELD_NUMBER

public static final int NAME_FIELD_NUMBER
Field Value
TypeDescription
int

PEEK_CARD_HEADER_FIELD_NUMBER

public static final int PEEK_CARD_HEADER_FIELD_NUMBER
Field Value
TypeDescription
int

SECTIONS_FIELD_NUMBER

public static final int SECTIONS_FIELD_NUMBER
Field Value
TypeDescription
int

SECTION_DIVIDER_STYLE_FIELD_NUMBER

public static final int SECTION_DIVIDER_STYLE_FIELD_NUMBER
Field Value
TypeDescription
int

Static Methods

getDefaultInstance()

public static Card getDefaultInstance()
Returns
TypeDescription
Card

getDescriptor()

public static final Descriptors.Descriptor getDescriptor()
Returns
TypeDescription
Descriptor

newBuilder()

public static Card.Builder newBuilder()
Returns
TypeDescription
Card.Builder

newBuilder(Card prototype)

public static Card.Builder newBuilder(Card prototype)
Parameter
NameDescription
prototypeCard
Returns
TypeDescription
Card.Builder

parseDelimitedFrom(InputStream input)

public static Card parseDelimitedFrom(InputStream input)
Parameter
NameDescription
inputInputStream
Returns
TypeDescription
Card
Exceptions
TypeDescription
IOException

parseDelimitedFrom(InputStream input, ExtensionRegistryLite extensionRegistry)

public static Card parseDelimitedFrom(InputStream input, ExtensionRegistryLite extensionRegistry)
Parameters
NameDescription
inputInputStream
extensionRegistryExtensionRegistryLite
Returns
TypeDescription
Card
Exceptions
TypeDescription
IOException

parseFrom(byte[] data)

public static Card parseFrom(byte[] data)
Parameter
NameDescription
databyte[]
Returns
TypeDescription
Card
Exceptions
TypeDescription
InvalidProtocolBufferException

parseFrom(byte[] data, ExtensionRegistryLite extensionRegistry)

public static Card parseFrom(byte[] data, ExtensionRegistryLite extensionRegistry)
Parameters
NameDescription
databyte[]
extensionRegistryExtensionRegistryLite
Returns
TypeDescription
Card
Exceptions
TypeDescription
InvalidProtocolBufferException

parseFrom(ByteString data)

public static Card parseFrom(ByteString data)
Parameter
NameDescription
dataByteString
Returns
TypeDescription
Card
Exceptions
TypeDescription
InvalidProtocolBufferException

parseFrom(ByteString data, ExtensionRegistryLite extensionRegistry)

public static Card parseFrom(ByteString data, ExtensionRegistryLite extensionRegistry)
Parameters
NameDescription
dataByteString
extensionRegistryExtensionRegistryLite
Returns
TypeDescription
Card
Exceptions
TypeDescription
InvalidProtocolBufferException

parseFrom(CodedInputStream input)

public static Card parseFrom(CodedInputStream input)
Parameter
NameDescription
inputCodedInputStream
Returns
TypeDescription
Card
Exceptions
TypeDescription
IOException

parseFrom(CodedInputStream input, ExtensionRegistryLite extensionRegistry)

public static Card parseFrom(CodedInputStream input, ExtensionRegistryLite extensionRegistry)
Parameters
NameDescription
inputCodedInputStream
extensionRegistryExtensionRegistryLite
Returns
TypeDescription
Card
Exceptions
TypeDescription
IOException

parseFrom(InputStream input)

public static Card parseFrom(InputStream input)
Parameter
NameDescription
inputInputStream
Returns
TypeDescription
Card
Exceptions
TypeDescription
IOException

parseFrom(InputStream input, ExtensionRegistryLite extensionRegistry)

public static Card parseFrom(InputStream input, ExtensionRegistryLite extensionRegistry)
Parameters
NameDescription
inputInputStream
extensionRegistryExtensionRegistryLite
Returns
TypeDescription
Card
Exceptions
TypeDescription
IOException

parseFrom(ByteBuffer data)

public static Card parseFrom(ByteBuffer data)
Parameter
NameDescription
dataByteBuffer
Returns
TypeDescription
Card
Exceptions
TypeDescription
InvalidProtocolBufferException

parseFrom(ByteBuffer data, ExtensionRegistryLite extensionRegistry)

public static Card parseFrom(ByteBuffer data, ExtensionRegistryLite extensionRegistry)
Parameters
NameDescription
dataByteBuffer
extensionRegistryExtensionRegistryLite
Returns
TypeDescription
Card
Exceptions
TypeDescription
InvalidProtocolBufferException

parser()

public static Parser<Card> parser()
Returns
TypeDescription
Parser<Card>

Methods

equals(Object obj)

public boolean equals(Object obj)
Parameter
NameDescription
objObject
Returns
TypeDescription
boolean
Overrides

getCardActions(int index)

public Card.CardAction getCardActions(int index)

The card's actions. Actions are added to the card's toolbar menu.

Google Workspace Add-ons:

For example, the following JSON constructs a card action menu with Settings and Send Feedback options:

<code><code> "card_actions": [ { "actionLabel": "Settings", "onClick": { "action": { "functionName": "goToView", "parameters": [ { "key": "viewType", "value": "SETTING" } ], "loadIndicator": "LoadIndicator.SPINNER" } } }, { "actionLabel": "Send Feedback", "onClick": { "openLink": { "url": "https://example.com/feedback" } } } ] </code></code>

repeated .google.apps.card.v1.Card.CardAction card_actions = 3;

Parameter
NameDescription
indexint
Returns
TypeDescription
Card.CardAction

getCardActionsCount()

public int getCardActionsCount()

The card's actions. Actions are added to the card's toolbar menu.

Google Workspace Add-ons:

For example, the following JSON constructs a card action menu with Settings and Send Feedback options:

<code><code> "card_actions": [ { "actionLabel": "Settings", "onClick": { "action": { "functionName": "goToView", "parameters": [ { "key": "viewType", "value": "SETTING" } ], "loadIndicator": "LoadIndicator.SPINNER" } } }, { "actionLabel": "Send Feedback", "onClick": { "openLink": { "url": "https://example.com/feedback" } } } ] </code></code>

repeated .google.apps.card.v1.Card.CardAction card_actions = 3;

Returns
TypeDescription
int

getCardActionsList()

public List<Card.CardAction> getCardActionsList()

The card's actions. Actions are added to the card's toolbar menu.

Google Workspace Add-ons:

For example, the following JSON constructs a card action menu with Settings and Send Feedback options:

<code><code> "card_actions": [ { "actionLabel": "Settings", "onClick": { "action": { "functionName": "goToView", "parameters": [ { "key": "viewType", "value": "SETTING" } ], "loadIndicator": "LoadIndicator.SPINNER" } } }, { "actionLabel": "Send Feedback", "onClick": { "openLink": { "url": "https://example.com/feedback" } } } ] </code></code>

repeated .google.apps.card.v1.Card.CardAction card_actions = 3;

Returns
TypeDescription
List<CardAction>

getCardActionsOrBuilder(int index)

public Card.CardActionOrBuilder getCardActionsOrBuilder(int index)

The card's actions. Actions are added to the card's toolbar menu.

Google Workspace Add-ons:

For example, the following JSON constructs a card action menu with Settings and Send Feedback options:

<code><code> "card_actions": [ { "actionLabel": "Settings", "onClick": { "action": { "functionName": "goToView", "parameters": [ { "key": "viewType", "value": "SETTING" } ], "loadIndicator": "LoadIndicator.SPINNER" } } }, { "actionLabel": "Send Feedback", "onClick": { "openLink": { "url": "https://example.com/feedback" } } } ] </code></code>

repeated .google.apps.card.v1.Card.CardAction card_actions = 3;

Parameter
NameDescription
indexint
Returns
TypeDescription
Card.CardActionOrBuilder

getCardActionsOrBuilderList()

public List<? extends Card.CardActionOrBuilder> getCardActionsOrBuilderList()

The card's actions. Actions are added to the card's toolbar menu.

Google Workspace Add-ons:

For example, the following JSON constructs a card action menu with Settings and Send Feedback options:

<code><code> "card_actions": [ { "actionLabel": "Settings", "onClick": { "action": { "functionName": "goToView", "parameters": [ { "key": "viewType", "value": "SETTING" } ], "loadIndicator": "LoadIndicator.SPINNER" } } }, { "actionLabel": "Send Feedback", "onClick": { "openLink": { "url": "https://example.com/feedback" } } } ] </code></code>

repeated .google.apps.card.v1.Card.CardAction card_actions = 3;

Returns
TypeDescription
List<? extends com.google.apps.card.v1.Card.CardActionOrBuilder>

getDefaultInstanceForType()

public Card getDefaultInstanceForType()
Returns
TypeDescription
Card

getDisplayStyle()

public Card.DisplayStyle getDisplayStyle()

In Google Workspace Add-ons, sets the display properties of the peekCardHeader.

Google Workspace Add-ons:

.google.apps.card.v1.Card.DisplayStyle display_style = 6;

Returns
TypeDescription
Card.DisplayStyle

The displayStyle.

getDisplayStyleValue()

public int getDisplayStyleValue()

In Google Workspace Add-ons, sets the display properties of the peekCardHeader.

Google Workspace Add-ons:

.google.apps.card.v1.Card.DisplayStyle display_style = 6;

Returns
TypeDescription
int

The enum numeric value on the wire for displayStyle.

getFixedFooter()

public Card.CardFixedFooter getFixedFooter()

The fixed footer shown at the bottom of this card.

Setting fixedFooter without specifying a primaryButton or a secondaryButton causes an error. For Chat apps, you can use fixed footers in dialogs, but not card messages.

Google Workspace Add-ons and Chat apps:

.google.apps.card.v1.Card.CardFixedFooter fixed_footer = 5;

Returns
TypeDescription
Card.CardFixedFooter

The fixedFooter.

getFixedFooterOrBuilder()

public Card.CardFixedFooterOrBuilder getFixedFooterOrBuilder()

The fixed footer shown at the bottom of this card.

Setting fixedFooter without specifying a primaryButton or a secondaryButton causes an error. For Chat apps, you can use fixed footers in dialogs, but not card messages.

Google Workspace Add-ons and Chat apps:

.google.apps.card.v1.Card.CardFixedFooter fixed_footer = 5;

Returns
TypeDescription
Card.CardFixedFooterOrBuilder

getHeader()

public Card.CardHeader getHeader()

The header of the card. A header usually contains a leading image and a title. Headers always appear at the top of a card.

.google.apps.card.v1.Card.CardHeader header = 1;

Returns
TypeDescription
Card.CardHeader

The header.

getHeaderOrBuilder()

public Card.CardHeaderOrBuilder getHeaderOrBuilder()

The header of the card. A header usually contains a leading image and a title. Headers always appear at the top of a card.

.google.apps.card.v1.Card.CardHeader header = 1;

Returns
TypeDescription
Card.CardHeaderOrBuilder

getName()

public String getName()

Name of the card. Used as a card identifier in card navigation.

Google Workspace Add-ons:

string name = 4;

Returns
TypeDescription
String

The name.

getNameBytes()

public ByteString getNameBytes()

Name of the card. Used as a card identifier in card navigation.

Google Workspace Add-ons:

string name = 4;

Returns
TypeDescription
ByteString

The bytes for name.

getParserForType()

public Parser<Card> getParserForType()
Returns
TypeDescription
Parser<Card>
Overrides

getPeekCardHeader()

public Card.CardHeader getPeekCardHeader()

When displaying contextual content, the peek card header acts as a placeholder so that the user can navigate forward between the homepage cards and the contextual cards.

Google Workspace Add-ons:

.google.apps.card.v1.Card.CardHeader peek_card_header = 7;

Returns
TypeDescription
Card.CardHeader

The peekCardHeader.

getPeekCardHeaderOrBuilder()

public Card.CardHeaderOrBuilder getPeekCardHeaderOrBuilder()

When displaying contextual content, the peek card header acts as a placeholder so that the user can navigate forward between the homepage cards and the contextual cards.

Google Workspace Add-ons:

.google.apps.card.v1.Card.CardHeader peek_card_header = 7;

Returns
TypeDescription
Card.CardHeaderOrBuilder

getSectionDividerStyle()

public Card.DividerStyle getSectionDividerStyle()

The divider style between sections.

.google.apps.card.v1.Card.DividerStyle section_divider_style = 9;

Returns
TypeDescription
Card.DividerStyle

The sectionDividerStyle.

getSectionDividerStyleValue()

public int getSectionDividerStyleValue()

The divider style between sections.

.google.apps.card.v1.Card.DividerStyle section_divider_style = 9;

Returns
TypeDescription
int

The enum numeric value on the wire for sectionDividerStyle.

getSections(int index)

public Card.Section getSections(int index)

Contains a collection of widgets. Each section has its own, optional header. Sections are visually separated by a line divider. For an example in Google Chat apps, see Card section.

repeated .google.apps.card.v1.Card.Section sections = 2;

Parameter
NameDescription
indexint
Returns
TypeDescription
Card.Section

getSectionsCount()

public int getSectionsCount()

Contains a collection of widgets. Each section has its own, optional header. Sections are visually separated by a line divider. For an example in Google Chat apps, see Card section.

repeated .google.apps.card.v1.Card.Section sections = 2;

Returns
TypeDescription
int

getSectionsList()

public List<Card.Section> getSectionsList()

Contains a collection of widgets. Each section has its own, optional header. Sections are visually separated by a line divider. For an example in Google Chat apps, see Card section.

repeated .google.apps.card.v1.Card.Section sections = 2;

Returns
TypeDescription
List<Section>

getSectionsOrBuilder(int index)

public Card.SectionOrBuilder getSectionsOrBuilder(int index)

Contains a collection of widgets. Each section has its own, optional header. Sections are visually separated by a line divider. For an example in Google Chat apps, see Card section.

repeated .google.apps.card.v1.Card.Section sections = 2;

Parameter
NameDescription
indexint
Returns
TypeDescription
Card.SectionOrBuilder

getSectionsOrBuilderList()

public List<? extends Card.SectionOrBuilder> getSectionsOrBuilderList()

Contains a collection of widgets. Each section has its own, optional header. Sections are visually separated by a line divider. For an example in Google Chat apps, see Card section.

repeated .google.apps.card.v1.Card.Section sections = 2;

Returns
TypeDescription
List<? extends com.google.apps.card.v1.Card.SectionOrBuilder>

getSerializedSize()

public int getSerializedSize()
Returns
TypeDescription
int
Overrides

hasFixedFooter()

public boolean hasFixedFooter()

The fixed footer shown at the bottom of this card.

Setting fixedFooter without specifying a primaryButton or a secondaryButton causes an error. For Chat apps, you can use fixed footers in dialogs, but not card messages.

Google Workspace Add-ons and Chat apps:

.google.apps.card.v1.Card.CardFixedFooter fixed_footer = 5;

Returns
TypeDescription
boolean

Whether the fixedFooter field is set.

hasHeader()

public boolean hasHeader()

The header of the card. A header usually contains a leading image and a title. Headers always appear at the top of a card.

.google.apps.card.v1.Card.CardHeader header = 1;

Returns
TypeDescription
boolean

Whether the header field is set.

hasPeekCardHeader()

public boolean hasPeekCardHeader()

When displaying contextual content, the peek card header acts as a placeholder so that the user can navigate forward between the homepage cards and the contextual cards.

Google Workspace Add-ons:

.google.apps.card.v1.Card.CardHeader peek_card_header = 7;

Returns
TypeDescription
boolean

Whether the peekCardHeader field is set.

hashCode()

public int hashCode()
Returns
TypeDescription
int
Overrides

internalGetFieldAccessorTable()

protected GeneratedMessageV3.FieldAccessorTable internalGetFieldAccessorTable()
Returns
TypeDescription
FieldAccessorTable
Overrides

isInitialized()

public final boolean isInitialized()
Returns
TypeDescription
boolean
Overrides

newBuilderForType()

public Card.Builder newBuilderForType()
Returns
TypeDescription
Card.Builder

newBuilderForType(GeneratedMessageV3.BuilderParent parent)

protected Card.Builder newBuilderForType(GeneratedMessageV3.BuilderParent parent)
Parameter
NameDescription
parentBuilderParent
Returns
TypeDescription
Card.Builder
Overrides

newInstance(GeneratedMessageV3.UnusedPrivateParameter unused)

protected Object newInstance(GeneratedMessageV3.UnusedPrivateParameter unused)
Parameter
NameDescription
unusedUnusedPrivateParameter
Returns
TypeDescription
Object
Overrides

toBuilder()

public Card.Builder toBuilder()
Returns
TypeDescription
Card.Builder

writeTo(CodedOutputStream output)

public void writeTo(CodedOutputStream output)
Parameter
NameDescription
outputCodedOutputStream
Overrides
Exceptions
TypeDescription
IOException