Class LinkPreview Stay organized with collections Save and categorize content based on your preferences.
Page Summary
Card action that displays a link preview card and smart chip in the host app.
Methods include printing JSON, setting the link preview title, setting the preview card, and setting the smart chip title.
setLinkPreviewTitlesets the title above the preview card, or defaults to the preview card header if unset.setPreviewCardsets the card displaying information about a third-party or non-Google link.setTitlesets the title in the smart chip for the link preview, or defaults to the preview card header if unset.
Card action that displays a link preview card and smart chip in the host app. For moreinformation, refer toPreview linkswith smart chips.
constdecoratedText=CardService.newDecoratedText().setTopLabel('Hello').setText('Hi!');constcardSection=CardService.newCardSection().addWidget(decoratedText);constcard=CardService.newCardBuilder().addSection(cardSection).build();constlinkPreview=CardService.newLinkPreview().setPreviewCard(card).setTitle('Smart chip title');
Methods
| Method | Return type | Brief description |
|---|---|---|
print | String | Prints the JSON representation of this object. |
set | Link | Sets the title that displays in the link preview above the preview card. |
set | Link | Sets the card that displays information about a link from a third-party or non-Google service. |
set | Link | Sets the title that displays in the smart chip for the link preview. |
Detailed documentation
printJson()
Prints the JSON representation of this object. This is for debugging only.
Return
String
setLinkPreviewTitle(title)
Sets the title that displays in the link preview above the preview card. If unset, the linkpreview displays the header of thePreview.
constlinkPreview=CardService.newLinkPreview().setLinkPreviewTitle('Link preview title');
Parameters
| Name | Type | Description |
|---|---|---|
title | String | The title of the link preview. |
Return
Link — This object, for chaining.
setPreviewCard(previewCard)
Sets the card that displays information about a link from a third-party or non-Google service.
constdecoratedText=CardService.newDecoratedText().setTopLabel('Hello').setText('Hi!');constcardSection=CardService.newCardSection().addWidget(decoratedText);constcard=CardService.newCardBuilder().addSection(cardSection).build();constlinkPreview=CardService.newLinkPreview().setPreviewCard(card).setTitle('Smart chip title');
Parameters
| Name | Type | Description |
|---|---|---|
preview | Card | The preview card. |
Return
Link — This object, for chaining.
setTitle(title)
Sets the title that displays in the smart chip for the link preview. If unset, the smart chipdisplays the header of thePreview.
constlinkPreview=CardService.newLinkPreview().setTitle('Smart chip title');
Parameters
| Name | Type | Description |
|---|---|---|
title | String | The title of the smart chip. |
Return
Link — This object, for chaining.
Except as otherwise noted, the content of this page is licensed under theCreative Commons Attribution 4.0 License, and code samples are licensed under theApache 2.0 License. For details, see theGoogle Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2025-12-03 UTC.