# Badge

Artifact: [androidx.car.app:app](https://developer.android.com/jetpack/androidx/releases/car-app) [View Source](https://cs.android.com/search?q=file:androidx/car/app/model/Badge.java+class:androidx.car.app.model.Badge) Added in [1.4.0](https://developer.android.com/jetpack/androidx/releases/car-app#1.4.0)

*** ** * ** ***


```
@CarProtocol
@RequiresCarApi(value = 8)
class Badge
```

<br />

*** ** * ** ***

Represents a badge that can be displayed as an overlay on top of an image.

A badge denotes some sort of call to action, notification, alert, etc. An example is badging of application icons in a launcher to add a number which denotes how many active notifications that application has.

Badges may have a dot which is a colored circle appearing in a different location to the icon.

## Summary

| ### Nested types |
|---|
| `class https://developer.android.com/reference/kotlin/androidx/car/app/model/Badge.Builder` A builder of `https://developer.android.com/reference/kotlin/androidx/car/app/model/Badge`. |

| ### Public functions |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | `https://developer.android.com/reference/kotlin/androidx/car/app/model/Badge#equals(java.lang.Object)(other: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-any/index.html?)` |
| `https://developer.android.com/reference/kotlin/androidx/car/app/model/CarColor?` | `[getBackgroundColor](https://developer.android.com/reference/kotlin/androidx/car/app/model/Badge#getBackgroundColor())()` **This function is deprecated.** use `https://developer.android.com/reference/kotlin/androidx/car/app/model/Badge#getDotColor()` instead. <br /> |
| `https://developer.android.com/reference/kotlin/androidx/car/app/model/CarColor?` | `https://developer.android.com/reference/kotlin/androidx/car/app/model/Badge#getDotColor()()` Returns the dot color. |
| `https://developer.android.com/reference/kotlin/androidx/car/app/model/CarIcon?` | `https://developer.android.com/reference/kotlin/androidx/car/app/model/Badge#getIcon()()` Returns the badge icon. |
| `https://developer.android.com/reference/kotlin/androidx/car/app/model/CarColor?` | `https://developer.android.com/reference/kotlin/androidx/car/app/model/Badge#getIconBackgroundColor()()` Returns the icon background color. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | `https://developer.android.com/reference/kotlin/androidx/car/app/model/Badge#hasDot()()` Returns whether the badge has a dot. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/car/app/model/Badge#hashCode()()` |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html` | `https://developer.android.com/reference/kotlin/androidx/car/app/model/Badge#toString()()` |

## Public functions

### equals

```
fun equals(other: Any?): Boolean
```

### getBackgroundColor

Added in [1.4.0](https://developer.android.com/jetpack/androidx/releases/car-app#1.4.0) Deprecated in [1.8.0](https://developer.android.com/jetpack/androidx/releases/car-app#1.8.0)

```
fun [getBackgroundColor](https://developer.android.com/reference/kotlin/androidx/car/app/model/Badge#getBackgroundColor())(): CarColor?
```

> [!CAUTION]
> **This function is deprecated.**   
>
> use `https://developer.android.com/reference/kotlin/androidx/car/app/model/Badge#getDotColor()` instead.

Returns the dot background color.

### getDotColor

Added in [1.8.0](https://developer.android.com/jetpack/androidx/releases/car-app#1.8.0)

```
fun getDotColor(): CarColor?
```

Returns the dot color.

### getIcon

Added in [1.4.0](https://developer.android.com/jetpack/androidx/releases/car-app#1.4.0)

```
fun getIcon(): CarIcon?
```

Returns the badge icon.

| See also |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/car/app/model/Badge.Builder#setIcon(androidx.car.app.model.CarIcon)` |   |

### getIconBackgroundColor

Added in [1.8.0](https://developer.android.com/jetpack/androidx/releases/car-app#1.8.0)

```
fun getIconBackgroundColor(): CarColor?
```

Returns the icon background color.

### hasDot

Added in [1.4.0](https://developer.android.com/jetpack/androidx/releases/car-app#1.4.0)

```
fun hasDot(): Boolean
```

Returns whether the badge has a dot.

| See also |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/car/app/model/Badge.Builder#setHasDot(boolean)` |   |

### hashCode

```
fun hashCode(): Int
```

### toString

```
fun toString(): String
```