Class Card (2.49.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 the components of a card or dialog.
  • 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/workspace/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
Type Description
int

DISPLAY_STYLE_FIELD_NUMBER

public static final int DISPLAY_STYLE_FIELD_NUMBER
Field Value
Type Description
int
public static final int FIXED_FOOTER_FIELD_NUMBER
Field Value
Type Description
int

HEADER_FIELD_NUMBER

public static final int HEADER_FIELD_NUMBER
Field Value
Type Description
int

NAME_FIELD_NUMBER

public static final int NAME_FIELD_NUMBER
Field Value
Type Description
int

PEEK_CARD_HEADER_FIELD_NUMBER

public static final int PEEK_CARD_HEADER_FIELD_NUMBER
Field Value
Type Description
int

SECTIONS_FIELD_NUMBER

public static final int SECTIONS_FIELD_NUMBER
Field Value
Type Description
int

SECTION_DIVIDER_STYLE_FIELD_NUMBER

public static final int SECTION_DIVIDER_STYLE_FIELD_NUMBER
Field Value
Type Description
int

Static Methods

getDefaultInstance()

public static Card getDefaultInstance()
Returns
Type Description
Card

getDescriptor()

public static final Descriptors.Descriptor getDescriptor()
Returns
Type Description
Descriptor

newBuilder()

public static Card.Builder newBuilder()
Returns
Type Description
Card.Builder

newBuilder(Card prototype)

public static Card.Builder newBuilder(Card prototype)
Parameter
Name Description
prototype Card
Returns
Type Description
Card.Builder

parseDelimitedFrom(InputStream input)

public static Card parseDelimitedFrom(InputStream input)
Parameter
Name Description
input InputStream
Returns
Type Description
Card
Exceptions
Type Description
IOException

parseDelimitedFrom(InputStream input, ExtensionRegistryLite extensionRegistry)

public static Card parseDelimitedFrom(InputStream input, ExtensionRegistryLite extensionRegistry)
Parameters
Name Description
input InputStream
extensionRegistry ExtensionRegistryLite
Returns
Type Description
Card
Exceptions
Type Description
IOException

parseFrom(byte[] data)

public static Card parseFrom(byte[] data)
Parameter
Name Description
data byte[]
Returns
Type Description
Card
Exceptions
Type Description
InvalidProtocolBufferException

parseFrom(byte[] data, ExtensionRegistryLite extensionRegistry)

public static Card parseFrom(byte[] data, ExtensionRegistryLite extensionRegistry)
Parameters
Name Description
data byte[]
extensionRegistry ExtensionRegistryLite
Returns
Type Description
Card
Exceptions
Type Description
InvalidProtocolBufferException

parseFrom(ByteString data)

public static Card parseFrom(ByteString data)
Parameter
Name Description
data ByteString
Returns
Type Description
Card
Exceptions
Type Description
InvalidProtocolBufferException

parseFrom(ByteString data, ExtensionRegistryLite extensionRegistry)

public static Card parseFrom(ByteString data, ExtensionRegistryLite extensionRegistry)
Parameters
Name Description
data ByteString
extensionRegistry ExtensionRegistryLite
Returns
Type Description
Card
Exceptions
Type Description
InvalidProtocolBufferException

parseFrom(CodedInputStream input)

public static Card parseFrom(CodedInputStream input)
Parameter
Name Description
input CodedInputStream
Returns
Type Description
Card
Exceptions
Type Description
IOException

parseFrom(CodedInputStream input, ExtensionRegistryLite extensionRegistry)

public static Card parseFrom(CodedInputStream input, ExtensionRegistryLite extensionRegistry)
Parameters
Name Description
input CodedInputStream
extensionRegistry ExtensionRegistryLite
Returns
Type Description
Card
Exceptions
Type Description
IOException

parseFrom(InputStream input)

public static Card parseFrom(InputStream input)
Parameter
Name Description
input InputStream
Returns
Type Description
Card
Exceptions
Type Description
IOException

parseFrom(InputStream input, ExtensionRegistryLite extensionRegistry)

public static Card parseFrom(InputStream input, ExtensionRegistryLite extensionRegistry)
Parameters
Name Description
input InputStream
extensionRegistry ExtensionRegistryLite
Returns
Type Description
Card
Exceptions
Type Description
IOException

parseFrom(ByteBuffer data)

public static Card parseFrom(ByteBuffer data)
Parameter
Name Description
data ByteBuffer
Returns
Type Description
Card
Exceptions
Type Description
InvalidProtocolBufferException

parseFrom(ByteBuffer data, ExtensionRegistryLite extensionRegistry)

public static Card parseFrom(ByteBuffer data, ExtensionRegistryLite extensionRegistry)
Parameters
Name Description
data ByteBuffer
extensionRegistry ExtensionRegistryLite
Returns
Type Description
Card
Exceptions
Type Description
InvalidProtocolBufferException

parser()

public static Parser<Card> parser()
Returns
Type Description
Parser<Card>

Methods

equals(Object obj)

public boolean equals(Object obj)
Parameter
Name Description
obj Object
Returns
Type Description
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
Name Description
index int
Returns
Type Description
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
Type Description
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
Type Description
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
Name Description
index int
Returns
Type Description
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
Type Description
List<? extends com.google.apps.card.v1.Card.CardActionOrBuilder>

getDefaultInstanceForType()

public Card getDefaultInstanceForType()
Returns
Type Description
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
Type Description
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
Type Description
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
Type Description
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
Type Description
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
Type Description
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
Type Description
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
Type Description
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
Type Description
ByteString

The bytes for name.

getParserForType()

public Parser<Card> getParserForType()
Returns
Type Description
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
Type Description
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
Type Description
Card.CardHeaderOrBuilder

getSectionDividerStyle()

public Card.DividerStyle getSectionDividerStyle()

The divider style between sections.

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

Returns
Type Description
Card.DividerStyle

The sectionDividerStyle.

getSectionDividerStyleValue()

public int getSectionDividerStyleValue()

The divider style between sections.

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

Returns
Type Description
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 Define a section of a card.

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

Parameter
Name Description
index int
Returns
Type Description
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 Define a section of a card.

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

Returns
Type Description
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 Define a section of a card.

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

Returns
Type Description
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 Define a section of a card.

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

Parameter
Name Description
index int
Returns
Type Description
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 Define a section of a card.

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

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

getSerializedSize()

public int getSerializedSize()
Returns
Type Description
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
Type Description
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
Type Description
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
Type Description
boolean

Whether the peekCardHeader field is set.

hashCode()

public int hashCode()
Returns
Type Description
int
Overrides

internalGetFieldAccessorTable()

protected GeneratedMessageV3.FieldAccessorTable internalGetFieldAccessorTable()
Returns
Type Description
FieldAccessorTable
Overrides

isInitialized()

public final boolean isInitialized()
Returns
Type Description
boolean
Overrides

newBuilderForType()

public Card.Builder newBuilderForType()
Returns
Type Description
Card.Builder

newBuilderForType(GeneratedMessageV3.BuilderParent parent)

protected Card.Builder newBuilderForType(GeneratedMessageV3.BuilderParent parent)
Parameter
Name Description
parent BuilderParent
Returns
Type Description
Card.Builder
Overrides

newInstance(GeneratedMessageV3.UnusedPrivateParameter unused)

protected Object newInstance(GeneratedMessageV3.UnusedPrivateParameter unused)
Parameter
Name Description
unused UnusedPrivateParameter
Returns
Type Description
Object
Overrides

toBuilder()

public Card.Builder toBuilder()
Returns
Type Description
Card.Builder

writeTo(CodedOutputStream output)

public void writeTo(CodedOutputStream output)
Parameter
Name Description
output CodedOutputStream
Overrides
Exceptions
Type Description
IOException