# WalletCard.Builder

Added in[API level 30](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)

# Builder

*** ** * ** ***

Kotlin\|[Java](https://developer.android.com/reference/android/service/quickaccesswallet/WalletCard.Builder "View this page in Java")  

```
class Builder
```

|---|--------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [kotlin.Any](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-any/index.html)                                                                               ||
| ↳ | [android.service.quickaccesswallet.WalletCard.Builder](https://developer.android.com/reference/kotlin/android/service/quickaccesswallet/WalletCard.Builder#) |

Builder for[WalletCard](https://developer.android.com/reference/kotlin/android/service/quickaccesswallet/WalletCard)objects. You must provide cardId, cardImage, contentDescription, and pendingIntent. If the card is opaque and should be shown with elevation, set hasShadow to true. cardIcon and cardLabel are optional.

## Summary

|                                                                                                                                                                                                                                                                                                                                                                                         Public constructors                                                                                                                                                                                                                                                                                                                                                                                          ||
|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|---|
| [Builder](https://developer.android.com/reference/kotlin/android/service/quickaccesswallet/WalletCard.Builder#Builder(kotlin.String,%20android.graphics.drawable.Icon,%20kotlin.CharSequence,%20android.app.PendingIntent))`(`cardId:` `[String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)`, `cardImage:` `[Icon](https://developer.android.com/reference/kotlin/android/graphics/drawable/Icon.html#)`, `contentDescription:` `[CharSequence](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-char-sequence/index.html)`, `pendingIntent:` `[PendingIntent](https://developer.android.com/reference/kotlin/android/app/PendingIntent.html#)`)` Called when a card type is not provided, in which case it defaults to CARD_TYPE_UNKNOWN.                       |
| [Builder](https://developer.android.com/reference/kotlin/android/service/quickaccesswallet/WalletCard.Builder#Builder(kotlin.String,%20kotlin.Int,%20android.graphics.drawable.Icon,%20kotlin.CharSequence,%20android.app.PendingIntent))`(`cardId:` `[String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)`, `cardType:` `[Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)`, `cardImage:` `[Icon](https://developer.android.com/reference/kotlin/android/graphics/drawable/Icon.html#)`, `contentDescription:` `[CharSequence](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-char-sequence/index.html)`, `pendingIntent:` `[PendingIntent](https://developer.android.com/reference/kotlin/android/app/PendingIntent.html#)`)` <br /> |

|                                                                                                                                                                                                                                                                                 Public methods                                                                                                                                                                                                                                                                                 ||
|----------------------------------------------------------------------------------------------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [WalletCard](https://developer.android.com/reference/kotlin/android/service/quickaccesswallet/WalletCard)                  | [build](https://developer.android.com/reference/kotlin/android/service/quickaccesswallet/WalletCard.Builder#build())`()` Builds a new[WalletCard](https://developer.android.com/reference/kotlin/android/service/quickaccesswallet/WalletCard)instance.                                                                                                                                                                                            |
| [WalletCard.Builder](https://developer.android.com/reference/kotlin/android/service/quickaccesswallet/WalletCard.Builder#) | [setCardIcon](https://developer.android.com/reference/kotlin/android/service/quickaccesswallet/WalletCard.Builder#setCardIcon(android.graphics.drawable.Icon))`(`cardIcon:` `[Icon](https://developer.android.com/reference/kotlin/android/graphics/drawable/Icon.html#)?`)` An icon may be shown alongside the card image to convey information about how the card can be used, or if some other action must be taken before using the card.      |
| [WalletCard.Builder](https://developer.android.com/reference/kotlin/android/service/quickaccesswallet/WalletCard.Builder#) | [setCardLabel](https://developer.android.com/reference/kotlin/android/service/quickaccesswallet/WalletCard.Builder#setCardLabel(kotlin.CharSequence))`(`cardLabel:` `[CharSequence](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-char-sequence/index.html)?`)` A card label may be shown alongside the card image to convey information about how the card can be used, or if some other action must be taken before using the card.       |
| [WalletCard.Builder](https://developer.android.com/reference/kotlin/android/service/quickaccesswallet/WalletCard.Builder#) | [setCardLocations](https://developer.android.com/reference/kotlin/android/service/quickaccesswallet/WalletCard.Builder#setCardLocations(kotlin.collections.MutableList))`(`cardLocations:` `[MutableList](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/-mutable-list/index.html)<[Location](https://developer.android.com/reference/kotlin/android/location/Location.html#)!>`)` Set of locations this card might be useful at. |
| [WalletCard.Builder](https://developer.android.com/reference/kotlin/android/service/quickaccesswallet/WalletCard.Builder#) | [setNonPaymentCardSecondaryImage](https://developer.android.com/reference/kotlin/android/service/quickaccesswallet/WalletCard.Builder#setNonPaymentCardSecondaryImage(android.graphics.drawable.Icon))`(`nonPaymentCardSecondaryImage:` `[Icon](https://developer.android.com/reference/kotlin/android/graphics/drawable/Icon.html#)?`)` Visual representation of the card when it is tapped.                                                      |

## Public constructors

### Builder

Added in[API level 30](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
Builder(
    cardId: String, 
    cardImage: Icon, 
    contentDescription: CharSequence, 
    pendingIntent: PendingIntent)
```

Called when a card type is not provided, in which case it defaults to CARD_TYPE_UNKNOWN. Calls[Builder.Builder(String, int, Icon, CharSequence, PendingIntent)](https://developer.android.com/reference/kotlin/android/service/quickaccesswallet/WalletCard.Builder#Builder(kotlin.String,%20kotlin.Int,%20android.graphics.drawable.Icon,%20kotlin.CharSequence,%20android.app.PendingIntent))

|                                                                    Parameters                                                                     ||
|----------------------|-----------------------------------------------------------------------------------------------------------------------------|
| `cardId`             | [String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html):This value cannot be`null`.                |
| `cardImage`          | [Icon](https://developer.android.com/reference/kotlin/android/graphics/drawable/Icon.html#):This value cannot be`null`.     |
| `contentDescription` | [CharSequence](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-char-sequence/index.html):This value cannot be`null`.   |
| `pendingIntent`      | [PendingIntent](https://developer.android.com/reference/kotlin/android/app/PendingIntent.html#):This value cannot be`null`. |

### Builder

Added in[API level 34](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
Builder(
    cardId: String, 
    cardType: Int, 
    cardImage: Icon, 
    contentDescription: CharSequence, 
    pendingIntent: PendingIntent)
```

|                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       Parameters                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        ||
|----------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `cardId`             | [String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html):The card id must be non-null and unique within the list of cards returned.**Note:** this card ID should**not**contain PII (Personally Identifiable Information, such as username or email address).                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              |
| `cardType`           | [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html):Integer representing the card type. The card type must be non-null. Value is[android.service.quickaccesswallet.WalletCard#CARD_TYPE_UNKNOWN](https://developer.android.com/reference/kotlin/android/service/quickaccesswallet/WalletCard#CARD_TYPE_UNKNOWN:kotlin.Int),[android.service.quickaccesswallet.WalletCard#CARD_TYPE_PAYMENT](https://developer.android.com/reference/kotlin/android/service/quickaccesswallet/WalletCard#CARD_TYPE_PAYMENT:kotlin.Int), or[android.service.quickaccesswallet.WalletCard#CARD_TYPE_NON_PAYMENT](https://developer.android.com/reference/kotlin/android/service/quickaccesswallet/WalletCard#CARD_TYPE_NON_PAYMENT:kotlin.Int)                                                                                                                                                                                                                |
| `cardImage`          | [Icon](https://developer.android.com/reference/kotlin/android/graphics/drawable/Icon.html#):The visual representation of the card. If the card image Icon is a bitmap, it should have a width of[android.service.quickaccesswallet.GetWalletCardsRequest#getCardWidthPx()](https://developer.android.com/reference/kotlin/android/service/quickaccesswallet/GetWalletCardsRequest#getCardWidthPx())and a height of[android.service.quickaccesswallet.GetWalletCardsRequest#getCardHeightPx()](https://developer.android.com/reference/kotlin/android/service/quickaccesswallet/GetWalletCardsRequest#getCardHeightPx()). If the card image does not have these dimensions, it may appear distorted when it is scaled to fit these dimensions on screen. Bitmaps must be of type[android.graphics.Bitmap.Config#HARDWARE](https://developer.android.com/reference/kotlin/android/graphics/Bitmap.Config.html#)for performance reasons. This value cannot be`null`. |
| `contentDescription` | [CharSequence](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-char-sequence/index.html):The content description of the card image. This field is required and may not be null or empty.**Note:** this message should**not**contain PII (Personally Identifiable Information, such as username or email address).                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            |
| `pendingIntent`      | [PendingIntent](https://developer.android.com/reference/kotlin/android/app/PendingIntent.html#):If the user performs a click on the card, this PendingIntent will be sent. If the device is locked, the wallet will first request device unlock before sending the pending intent. It is recommended that the pending intent be immutable (use[android.app.PendingIntent#FLAG_IMMUTABLE](https://developer.android.com/reference/kotlin/android/app/PendingIntent.html#FLAG_IMMUTABLE:kotlin.Int)). This value cannot be`null`.                                                                                                                                                                                                                                                                                                                                                                                                                                   |

## Public methods

### build

Added in[API level 30](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
fun build(): WalletCard
```

Builds a new[WalletCard](https://developer.android.com/reference/kotlin/android/service/quickaccesswallet/WalletCard)instance.

|                                                                          Return                                                                          ||
|-----------------------------------------------------------------------------------------------------------|-----------------------------------------------|
| [WalletCard](https://developer.android.com/reference/kotlin/android/service/quickaccesswallet/WalletCard) | A built response. This value cannot be`null`. |

### setCardIcon

Added in[API level 30](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
fun setCardIcon(cardIcon: Icon?): WalletCard.Builder
```

An icon may be shown alongside the card image to convey information about how the card can be used, or if some other action must be taken before using the card. For example, an NFC logo could indicate that the card is NFC-enabled and will be provided to an NFC terminal if the phone is held in close proximity to the NFC reader. This field is optional.

If the supplied Icon is backed by a bitmap, it should have width and height[GetWalletCardsRequest.getIconSizePx()](https://developer.android.com/reference/kotlin/android/service/quickaccesswallet/GetWalletCardsRequest#getIconSizePx()).

|                                                            Parameters                                                             ||
|------------|-----------------------------------------------------------------------------------------------------------------------|
| `cardIcon` | [Icon](https://developer.android.com/reference/kotlin/android/graphics/drawable/Icon.html#)?:This value may be`null`. |

|                                                                         Return                                                                          ||
|----------------------------------------------------------------------------------------------------------------------------|-----------------------------|
| [WalletCard.Builder](https://developer.android.com/reference/kotlin/android/service/quickaccesswallet/WalletCard.Builder#) | This value cannot be`null`. |

### setCardLabel

Added in[API level 30](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
fun setCardLabel(cardLabel: CharSequence?): WalletCard.Builder
```

A card label may be shown alongside the card image to convey information about how the card can be used, or if some other action must be taken before using the card. For example, an NFC-enabled card could be labeled "Hold near reader" to inform the user of how to use NFC cards when interacting with an NFC reader. This field is optional.**Note:** this card label should**not**contain PII (Personally Identifiable Information, such as username or email address). If the provided label is too long to fit on one line, it may be truncated and ellipsized.

|                                                              Parameters                                                              ||
|-------------|-------------------------------------------------------------------------------------------------------------------------|
| `cardLabel` | [CharSequence](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-char-sequence/index.html)?:This value may be`null`. |

|                                                                         Return                                                                          ||
|----------------------------------------------------------------------------------------------------------------------------|-----------------------------|
| [WalletCard.Builder](https://developer.android.com/reference/kotlin/android/service/quickaccesswallet/WalletCard.Builder#) | This value cannot be`null`. |

### setCardLocations

Added in[API level 34](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
fun setCardLocations(cardLocations: MutableList<Location!>): WalletCard.Builder
```

Set of locations this card might be useful at. If[android.content.pm.PackageManager#FEATURE_WALLET_LOCATION_BASED_SUGGESTIONS](https://developer.android.com/reference/kotlin/android/content/pm/PackageManager.html#FEATURE_WALLET_LOCATION_BASED_SUGGESTIONS:kotlin.String)is enabled, the card might be shown to the user when a user is near one of these locations.

|                                                                                                                     Parameters                                                                                                                      ||
|-----------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `cardLocations` | [MutableList](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/-mutable-list/index.html)\<[Location](https://developer.android.com/reference/kotlin/android/location/Location.html#)!\>:This value cannot be`null`. |

|                                                                         Return                                                                          ||
|----------------------------------------------------------------------------------------------------------------------------|-----------------------------|
| [WalletCard.Builder](https://developer.android.com/reference/kotlin/android/service/quickaccesswallet/WalletCard.Builder#) | This value cannot be`null`. |

### setNonPaymentCardSecondaryImage

Added in[API level 34](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
fun setNonPaymentCardSecondaryImage(nonPaymentCardSecondaryImage: Icon?): WalletCard.Builder
```

Visual representation of the card when it is tapped. May include additional information unique to the card, such as a barcode or number. Only valid for CARD_TYPE_NON_PAYMENT.

|                                                                      Parameters                                                                       ||
|--------------------------------|-----------------------------------------------------------------------------------------------------------------------|
| `nonPaymentCardSecondaryImage` | [Icon](https://developer.android.com/reference/kotlin/android/graphics/drawable/Icon.html#)?:This value may be`null`. |

|                                                                         Return                                                                          ||
|----------------------------------------------------------------------------------------------------------------------------|-----------------------------|
| [WalletCard.Builder](https://developer.android.com/reference/kotlin/android/service/quickaccesswallet/WalletCard.Builder#) | This value cannot be`null`. |